[ticket/17365] Include $countable_keywords with spaces before -, + and |

This reverses the previous commit and tries a different approach which may be more friendly to the tests
This commit is contained in:
crowjake 2024-07-06 01:25:19 +01:00 committed by GitHub
parent f03453c063
commit e9c08a1689
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -289,7 +289,6 @@ class fulltext_native extends \phpbb\search\base
'#(\+|\-)(?:\+|\-)+#',
'#\(\|#',
'#\|\)#',
'#(?<!\s)(\+|\-|\|)#',
);
$replace = array(
' ',
@ -297,11 +296,14 @@ class fulltext_native extends \phpbb\search\base
'$1',
'(',
')',
' $1',
);
$keywords = preg_replace($match, $replace, $keywords);
$num_keywords = count(explode(' ', $keywords));
// Ensure a space exists before +, - and | to make the split and count work correctly
$countable_keywords = preg_replace('/(?<!\s)(\+|\-|\|)/', ' $1', $keywords);
$num_keywords = count(explode(' ', $countable_keywords));
// We limit the number of allowed keywords to minimize load on the database
if ($this->config['max_num_search_keywords'] && $num_keywords > $this->config['max_num_search_keywords'])