From defb807dbc3967b41f985c49e16f6091537be414 Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 16 Mar 2023 20:15:40 +0700 Subject: [PATCH] [ticket/17115] Fix PHP warning for space+hyphen ending search query PHPBB3-17115 --- phpBB/phpbb/search/fulltext_native.php | 2 +- tests/functional/search/base.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php index 59fab38026..7fc5e002ba 100644 --- a/phpBB/phpbb/search/fulltext_native.php +++ b/phpBB/phpbb/search/fulltext_native.php @@ -393,7 +393,7 @@ class fulltext_native extends \phpbb\search\base $word = substr($word, 1); // a group of which at least one may not be in the resulting posts - if ($word[0] == '(') + if (isset($word[0]) && $word[0] == '(') { $word = array_unique(explode('|', substr($word, 1, -1))); $mode = 'must_exclude_one'; diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php index 41a14a8113..033c31c396 100644 --- a/tests/functional/search/base.php +++ b/tests/functional/search/base.php @@ -164,6 +164,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case } $this->assert_search_not_found('loremipsumdedo'); + $this->assert_search_not_found('loremipsumdedo+-'); // test search query ending with the space followed by hyphen $this->assert_search_not_found('barsearch+-testing'); // test excluding keyword $this->assert_search_for_author_not_found('authornotexists');