Added casts to binary for regexp comparison in mysql. mysql rejects comparison of UTF with binary strings.

see https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-22.html#mysqld-8-0-22-feature
The SQL statements also work for mariadb.
This commit is contained in:
cluster15 2025-05-23 09:56:28 +02:00
parent 8e0a3d00bb
commit 6e84c0ade7
3 changed files with 9 additions and 7 deletions

View file

@ -254,7 +254,9 @@ class Contact extends BaseModule
$searching = true;
$search_hdr = $search;
$search_txt = preg_quote(trim($search, ' @!'));
$sql_extra .= " AND (`name` REGEXP ? OR `url` REGEXP ? OR `nick` REGEXP ? OR `addr` REGEXP ? OR `alias` REGEXP ?)";
$sql_extra .= " AND (CAST(`name` AS BINARY) REGEXP BINARY ? OR CAST(`url` AS BINARY) REGEXP BINARY ?";
$sql_extra .= " OR CAST(`nick` AS BINARY) REGEXP BINARY ? OR CAST(`addr` AS BINARY) REGEXP BINARY ?";
$sql_extra .= " OR CAST(`alias` AS BINARY) REGEXP BINARY ?)";
$sql_values[] = $search_txt;
$sql_values[] = $search_txt;
$sql_values[] = $search_txt;