aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@phpbb.com>2015-01-29 00:02:41 +0100
committerAndreas Fischer <bantu@phpbb.com>2015-01-29 00:02:41 +0100
commitf0f88c287c4969eb9c1783ace2faa8a44cf59bd9 (patch)
treec13377bd60355af710edde5342a434a0a4abea6f
parente3e427fa2470c6830220671216e1c0cfcd4d81ec (diff)
parent35edd7a0433b5d8f74febf62f192aabaefbe61b6 (diff)
downloadforums-f0f88c287c4969eb9c1783ace2faa8a44cf59bd9.tar
forums-f0f88c287c4969eb9c1783ace2faa8a44cf59bd9.tar.gz
forums-f0f88c287c4969eb9c1783ace2faa8a44cf59bd9.tar.bz2
forums-f0f88c287c4969eb9c1783ace2faa8a44cf59bd9.tar.xz
forums-f0f88c287c4969eb9c1783ace2faa8a44cf59bd9.zip
Merge pull request #3338 from dhruvgoel92/ticket/12933
[ticket/12933] Handle *wildcard character in native search * dhruvgoel92/ticket/12933: [ticket/12933] Add test cases for * wildcard searches [ticket/12933] Handle case when * is last character of word
-rw-r--r--phpBB/phpbb/search/fulltext_native.php2
-rw-r--r--tests/search/fixtures/posts.xml10
-rw-r--r--tests/search/native_test.php50
3 files changed, 61 insertions, 1 deletions
diff --git a/phpBB/phpbb/search/fulltext_native.php b/phpBB/phpbb/search/fulltext_native.php
index 8865d37712..93ea46ca60 100644
--- a/phpBB/phpbb/search/fulltext_native.php
+++ b/phpBB/phpbb/search/fulltext_native.php
@@ -300,7 +300,7 @@ class fulltext_native extends \phpbb\search\base
$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();
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 @@
<value>commonword</value>
<value>commonword</value>
</row>
+ <row>
+ <value>baaz</value>
+ <value>baaz</value>
+ <value>baaz</value>
+ </row>
</table>
<table name="phpbb_search_wordlist">
<column>word_id</column>
@@ -39,5 +44,10 @@
<value>commonword</value>
<value>1</value>
</row>
+ <row>
+ <value>4</value>
+ <value>baaz</value>
+ <value>0</value>
+ </row>
</table>
</dataset>
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);
}
@@ -56,6 +58,54 @@ class phpbb_search_native_test extends phpbb_search_test_case
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',
true,