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 835cf58 commit ba2ba25
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ List of changes between releases of Extension:JsCalendar.

== master branch (will become JsCalendar 0.4.1 or 0.5.0, depending on magnitude of changes) ==

No changes since JsCalendar 0.4.0.
Features:
* Support PostgreSQL.

== JsCalendar 0.4.0 ==

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ The following parameter within `<EventCalendar>` will change the color of event
keywordcolor.arctic = yellow
keywordcolor.statistically = lightgreen

### Requirements

* MySQL (this extension doesn't support PostgreSQL. Patches that add PostgreSQL support are very welcome, but maintainter of this extension won't be implementing this himself).

### Installation

1. Deploy the files to `extensions/JsCalendar`.
Expand Down
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 ba2ba25

Please sign in to comment.