fixes #1118 competition between regexp models

This commit is contained in:
plegall 2021-03-09 11:32:36 +01:00
parent a02edff655
commit d0497f035c

View file

@ -933,8 +933,20 @@ function qsearch_get_text_token_search_sql($token, $fields)
if (!$use_ft)
{// odd term or too short for full text search; fallback to regex but unfortunately this is diacritic/accent sensitive
$pre = ($token->modifier & QST_WILDCARD_BEGIN) ? '' : '[[:<:]]';
$post = ($token->modifier & QST_WILDCARD_END) ? '' : '[[:>:]]';
if (!isset($page['use_regexp_ICU']))
{
// Prior to MySQL 8.0.4, MySQL used the Henry Spencer regular expression library to support
// regular expression operations, rather than International Components for Unicode (ICU)
$page['use_regexp_ICU'] = false;
$db_version = pwg_get_db_version();
if (!preg_match('/mariadb/i', $db_version) and version_compare($db_version, '8.0.4', '>'))
{
$page['use_regexp_ICU'] = true;
}
}
$pre = ($token->modifier & QST_WILDCARD_BEGIN) ? '' : ($page['use_regexp_ICU'] ? '\\\\b' : '[[:<:]]');
$post = ($token->modifier & QST_WILDCARD_END) ? '' : ($page['use_regexp_ICU'] ? '\\\\b' : '[[:>:]]');
foreach( $fields as $field)
$clauses[] = $field.' REGEXP \''.$pre.addslashes(preg_quote($variant)).$post.'\'';
}