From af1e5cb9bc0c81e36a095b70073f0d23cf4554a9 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sat, 20 Dec 2025 11:06:39 +0100 Subject: More uniform SQL search and PHP search (#8329) * More uniform SQL search and PHP search The behaviour depends though on the database. Improve https://github.com/FreshRSS/FreshRSS/discussions/8265#discussioncomment-15278980 * Try to use transliterator_transliterate function instead --- app/Models/DatabaseDAOPGSQL.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app/Models/DatabaseDAOPGSQL.php') diff --git a/app/Models/DatabaseDAOPGSQL.php b/app/Models/DatabaseDAOPGSQL.php index 3fa70cd88..116f8816e 100644 --- a/app/Models/DatabaseDAOPGSQL.php +++ b/app/Models/DatabaseDAOPGSQL.php @@ -99,4 +99,19 @@ SQL; } return $ok; } + + #[\Override] + public static function strilike(string $haystack, string $needle): bool { + if (function_exists('mb_stripos')) { + return mb_stripos($haystack, $needle, 0, 'UTF-8') !== false; + } + if (function_exists('transliterator_transliterate')) { + $haystack_ = transliterator_transliterate('Lower', $haystack); + $needle_ = transliterator_transliterate('Lower', $needle); + if ($haystack_ !== false && $needle_ !== false) { + return str_contains($haystack_, $needle_); + } + } + return stripos($haystack, $needle) !== false; + } } -- cgit v1.2.3