Skip to content

Commit

Permalink
pkp#10060 Delegated lower case comparison to the database
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasraoni committed Jun 25, 2024
1 parent 07aad03 commit 6ec126e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions classes/announcement/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ public function getQueryBuilder(): Builder
$qb->whereIn('a.announcement_id', function (Builder $q) use ($words) {
$q->select('announcement_id')->from($this->dao->settingsTable);
foreach ($words as $word) {
$word = strtolower(addcslashes($word, '%_'));
$word = addcslashes($word, '%_');
$q->where(
fn (Builder $q) => $q
->where(fn (Builder $q) => $q->where('setting_name', 'title')->where(DB::raw('lower(setting_value)'), 'LIKE', "%{$word}%"))
->orWhere(fn (Builder $q) => $q->where('setting_name', 'descriptionShort')->where(DB::raw('lower(setting_value)'), 'LIKE', "%{$word}%"))
->orWhere(fn (Builder $q) => $q->where('setting_name', 'description')->where(DB::raw('lower(setting_value)'), 'LIKE', "%{$word}%"))
->where(fn (Builder $q) => $q->where('setting_name', 'title')->whereRaw('LOWER(setting_value) LIKE ?', ["%{$word}%"]))
->orWhere(fn (Builder $q) => $q->where('setting_name', 'descriptionShort')->whereRaw('LOWER(setting_value) LIKE ?', ["%{$word}%"]))
->orWhere(fn (Builder $q) => $q->where('setting_name', 'description')->whereRaw('LOWER(setting_value) LIKE ?', ["%{$word}%"]))
);
}
});
Expand Down

0 comments on commit 6ec126e

Please sign in to comment.