From be90e9745242dbfa26aa7ebfbe41c80114a4baad Mon Sep 17 00:00:00 2001 From: Dhruv Date: Wed, 28 Jan 2015 21:37:03 +0530 Subject: [PATCH 1/2] [ticket/12933] Handle case when * is last character of word PHPBB3-12933 --- phpBB/includes/search/fulltext_native.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index 29c5a72874..948911bbfe 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -204,7 +204,7 @@ class fulltext_native extends search_backend $this->search_query = $keywords; $exact_words = array(); - preg_match_all('#([^\\s+\\-|*()]+)(?:$|[\\s+\\-|()])#u', $keywords, $exact_words); + preg_match_all('#([^\\s+\\-|()]+)(?:$|[\\s+\\-|()])#u', $keywords, $exact_words); $exact_words = $exact_words[1]; $common_ids = $words = array(); From 35edd7a0433b5d8f74febf62f192aabaefbe61b6 Mon Sep 17 00:00:00 2001 From: Dhruv Date: Wed, 28 Jan 2015 21:46:38 +0530 Subject: [PATCH 2/2] [ticket/12933] Add test cases for * wildcard searches PHPBB3-12933 --- tests/search/fixtures/posts.xml | 10 +++++++ tests/search/native_test.php | 50 +++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/tests/search/fixtures/posts.xml b/tests/search/fixtures/posts.xml index 7b249ee303..16232b8f39 100644 --- a/tests/search/fixtures/posts.xml +++ b/tests/search/fixtures/posts.xml @@ -19,6 +19,11 @@ commonword commonword + + baaz + baaz + baaz + word_id @@ -39,5 +44,10 @@ commonword1 + + 4 + baaz + 0 +
diff --git a/tests/search/native_test.php b/tests/search/native_test.php index f681a62fce..61fde7d098 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -35,6 +35,8 @@ class phpbb_search_native_test extends phpbb_search_test_case $this->db = $this->new_dbal(); $error = null; $class = self::get_search_wrapper('\phpbb\search\fulltext_native'); + $config['fulltext_native_min_chars'] = 2; + $config['fulltext_native_max_chars'] = 14; $this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user); } @@ -55,6 +57,54 @@ class phpbb_search_native_test extends phpbb_search_test_case array(), array(), ), + array( + 'baaz*', + 'all', + true, + array('\'baaz%\''), + array(), + array(), + ), + array( + 'ba*az', + 'all', + true, + array('\'ba%az\''), + array(), + array(), + ), + array( + 'ba*z', + 'all', + true, + array('\'ba%z\''), + array(), + array(), + ), + array( + 'baa* baaz*', + 'all', + true, + array('\'baa%\'', '\'baaz%\''), + array(), + array(), + ), + array( + 'ba*z baa*', + 'all', + true, + array('\'ba%z\'', '\'baa%\''), + array(), + array(), + ), + array( + 'baaz* commonword', + 'all', + true, + array('\'baaz%\''), + array(), + array('commonword'), + ), array( 'foo bar', 'all',