From a3033a4a8650e2fcbe8b2e8e9f3044f872c0ea14 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sat, 5 Oct 2013 21:09:52 +0530 Subject: [PATCH 1/2] [ticket/11288] Handle +,- without preceeding whitespace characters PHPBB3-11288 --- phpBB/includes/search/fulltext_native.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 2ee119ccfe..29c5a72874 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -232,6 +232,12 @@ class fulltext_native extends search_backend $db->sql_freeresult($result); } + // Handle +, - without preceeding whitespace character + $match = array('#(\S)\+#', '#(\S)-#'); + $replace = array('$1 +', '$1 +'); + + $keywords = preg_replace($match, $replace, $keywords); + // now analyse the search query, first split it using the spaces $query = explode(' ', $keywords); From baed78bde7ec12be380c01518bc7c0f030a3ae61 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Sun, 9 Mar 2014 22:30:22 +0530 Subject: [PATCH 2/2] [ticket/11288] Add unit test cases for foo-bar like queries foo-bar and foo -bar are interpreted differently by native search backend now. PHPBB3-11288 --- tests/search/native_test.php | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 4911160cc0..e860a4f89a 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -119,6 +119,55 @@ class phpbb_search_native_test extends phpbb_search_test_case array(1, 2), array(), ), + array( + 'foo -foo', + 'all', + true, + array(1), + array(1), + array(), + ), + array( + '-foo foo', + 'all', + true, + array(1), + array(1), + array(), + ), + // some creative edge cases + array( + 'foo foo-', + 'all', + true, + array(1), + array(), + array(), + ), + array( + 'foo- foo', + 'all', + true, + array(1), + array(), + array(), + ), + array( + 'foo-bar', + 'all', + true, + array(1, 2), + array(), + array(), + ), + array( + 'foo-bar-foo', + 'all', + true, + array(1, 2), + array(), + array(), + ), // all common array( 'commonword',