FIX Filter out all FULLTEXT BOOLEAN chars

The query might still work depending on where these chars are placed,
but it seems weird to only remove *some* of the valid chars here.
See https://dev.mysql.com/doc/refman/5.6/en/fulltext-boolean.html

Note that the query runs both the actual boolean query with chars,
and then a separate relevance search without them.
This commit is contained in:
Ingo Schommer 2020-04-09 10:30:37 +12:00
parent 0215fdd262
commit 2c5deceeb4
2 changed files with 3 additions and 3 deletions

View File

@ -227,8 +227,9 @@ class MySQLDatabase extends Database implements TransactionManager
$match[$fileClass] = "MATCH (Name, Title) AGAINST ('$keywords' $boolean) AND ClassName = '$fileClassSQL'";
// We make the relevance search by converting a boolean mode search into a normal one
$relevanceKeywords = str_replace(array('*', '+', '-'), '', $keywords);
$htmlEntityRelevanceKeywords = str_replace(array('*', '+', '-'), '', $htmlEntityKeywords);
$booleanChars = ['*', '+', '@', '-', '(', ')', '<', '>'];
$relevanceKeywords = str_replace($booleanChars, '', $keywords);
$htmlEntityRelevanceKeywords = str_replace($booleanChars, '', $htmlEntityKeywords);
$relevance[$pageClass] = "MATCH (Title, MenuTitle, Content, MetaDescription) "
. "AGAINST ('$relevanceKeywords') "
. "+ MATCH (Title, MenuTitle, Content, MetaDescription) AGAINST ('$htmlEntityRelevanceKeywords')";

View File

@ -34,5 +34,4 @@ class TestObject extends DataObject implements TestOnly
'columns' => ['ColumnE'],
],
);
}