From 626e9652f32ba7868c5b5a4ff677183b002aa39c Mon Sep 17 00:00:00 2001 From: Edward Chernenko Date: Mon, 30 Dec 2024 10:16:07 +0300 Subject: [PATCH] (postgres) Remove named capture brackets from regex in SQL query --- includes/FindEventPagesQuery.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/FindEventPagesQuery.php b/includes/FindEventPagesQuery.php index a99ac52..ba26d10 100644 --- a/includes/FindEventPagesQuery.php +++ b/includes/FindEventPagesQuery.php @@ -109,6 +109,10 @@ public function setTitleRegex( $regex ) { return; } + // Don't include named capture brackets into the SQL query, + // they are not needed there, and PostgreSQL can't parse a regex that has them. + $regex = str_replace( [ '?', '?' ], [], $regex ); + $rlike = $this->dbr->getType() === 'postgres' ? '~' : 'RLIKE'; $this->where[] = "page_title $rlike " . $this->dbr->addQuotes( $regex ); }