Skip to content

Commit

Permalink
(postgres) Remove named capture brackets from regex in SQL query
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Dec 30, 2024
1 parent 377875a commit 626e965
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions includes/FindEventPagesQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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( [ '?<start>', '?<end>' ], [], $regex );

$rlike = $this->dbr->getType() === 'postgres' ? '~' : 'RLIKE';
$this->where[] = "page_title $rlike " . $this->dbr->addQuotes( $regex );
}
Expand Down

0 comments on commit 626e965

Please sign in to comment.