Manybubbles has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/133195

Change subject: Allow spaces after the : in intitle and incategory
......................................................................

Allow spaces after the : in intitle and incategory

This is for backwards compatibility  with lsearchd.

Bug: 65237
Change-Id: I3cd9953d0407541a7f97c22bf13060f5f8743baa
---
M includes/Searcher.php
M tests/browser/features/hastemplate.feature
M tests/browser/features/incategory.feature
M tests/browser/features/intitle.feature
4 files changed, 25 insertions(+), 25 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/95/133195/1

diff --git a/includes/Searcher.php b/includes/Searcher.php
index b9602cd..ef1e39b 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -330,7 +330,7 @@
                // Match filters that look like foobar:thing or foobar:"thing 
thing"
                // The {7,15} keeps this from having horrible performance on 
big strings
                $this->extractSpecialSyntaxFromTerm(
-                       '/(?<key>[a-z\\-]{7,15}):(?<value>(?:"[^"]+")|(?:[^ 
"]+)) ?/',
+                       '/(?<key>[a-z\\-]{7,15}):\s*(?<value>(?:"[^"]+")|(?:[^ 
"]+)) ?/',
                        function ( $matches ) use ( $searcher, &$filters, 
&$notFilters, &$boostTemplates,
                                        &$searchContainedSyntax ) {
                                $key = $matches['key'];
diff --git a/tests/browser/features/hastemplate.feature 
b/tests/browser/features/hastemplate.feature
index d5d843d..16dace2 100644
--- a/tests/browser/features/hastemplate.feature
+++ b/tests/browser/features/hastemplate.feature
@@ -1,35 +1,29 @@
-@clean @phantomjs
+@clean @phantomjs @filters @hastemplate
 Feature: Searches with the hastemplate filter
   Background:
     Given I am at a random page
 
-  @filters @hastemplate
   Scenario: hastemplate: finds pages with matching templates (when you don't 
specify a namespace, Template is assumed)
     When I search for hastemplate:"Template Test"
     Then Two Words is the first search result
     And there is no link to create a new page from the search result
 
-  @filters @hastemplate
   Scenario: hastemplate: finds pages with matching templates with namespace 
specified
     When I search for hastemplate:"Template:Template Test"
     Then Two Words is the first search result
 
-  @filters @hastemplate
   Scenario: hastemplate: finds pages with matching templates that aren't in 
the template namespace if you prefix them with the namespace
     When I search for hastemplate:"Talk:TalkTemplate"
     Then HasTTemplate is the first search result
 
-  @filters @hastemplate
   Scenario: hastemplate: finds pages which contain a template in the main 
namespace if they are prefixed with : (which is how you'd transclude them)
     When I search for hastemplate::MainNamespaceTemplate
     Then HasMainNSTemplate is the first search result
 
-  @filters @hastemplate
   Scenario: hastemplate: doesn't find pages which contain a template in the 
main namespace if you don't prefix the name with : (that is for the Template 
namespace)
     When I search for hastemplate:MainNamespaceTemplate
     Then HasMainNSTemplate is not in the search results
 
-  @filters @hastemplate
   Scenario: -hastemplate removes pages with matching templates
     When I search for -hastemplate:"Template Test" catapult
     Then Two Words is not in the search results
diff --git a/tests/browser/features/incategory.feature 
b/tests/browser/features/incategory.feature
index bcd82d5..924427e 100644
--- a/tests/browser/features/incategory.feature
+++ b/tests/browser/features/incategory.feature
@@ -1,9 +1,8 @@
-@clean @phantomjs
+@clean @phantomjs @filters
 Feature: Searches with the incategory filter
   Background:
     Given I am at a random page
 
-  @filters
   Scenario: incategory: only includes pages with the category
     When I search for incategory:weaponry
     Then Catapult is in the search results
@@ -11,44 +10,43 @@
     But Two Words is not in the search results
     And there is no link to create a new page from the search result
 
-  @filters
   Scenario: incategory: can be combined with other text
     When I search for incategory:weaponry amazing
     Then Amazing Catapult is the first search result
     And there is no link to create a new page from the search result
 
-  @filters
   Scenario: -incategory: excludes pages with the category
     When I search for -incategory:weaponry incategory:twowords
     Then Two Words is the first search result
     And there is no link to create a new page from the search result
 
-  @filters
   Scenario: incategory: works on categories from templates
     When I search for incategory:templatetagged incategory:twowords
     Then Two Words is the first search result
 
-  @filters
   Scenario: incategory works with multi word categories
     When I search for incategory:"Categorywith Twowords"
     Then Two Words is the first search result
 
-  @filters
   Scenario: incategory works with can find two word categories with spaces
     When I search for incategory:Categorywith_Twowords
     Then Two Words is the first search result
 
-  @filters
   Scenario: incategory: when passed a quoted category that doesn't exist finds 
nothing even though there is a category that matches one of the words
     When I search for incategory:"Dontfindme Weaponry"
     Then there are no search results
 
-  @filters
   Scenario: incategory when passed a single word category doesn't find a two 
word category that contains that word
     When I search for incategory:ASpace
     Then there are no search results
 
-  @filters
   Scenario: incategory: finds a multiword category when it is surrounded by 
quotes
     When I search for incategory:"CategoryWith ASpace"
     Then IHaveATwoWordCategory is the first search result
+
+  Scenario: incategory: can handle a space after the :
+    When I search for incategory: weaponry
+    Then Catapult is in the search results
+    And Amazing Catapult is in the search results
+    But Two Words is not in the search results
+    And there is no link to create a new page from the search result
\ No newline at end of file
diff --git a/tests/browser/features/intitle.feature 
b/tests/browser/features/intitle.feature
index ebe356e..1edbd27 100644
--- a/tests/browser/features/intitle.feature
+++ b/tests/browser/features/intitle.feature
@@ -1,9 +1,8 @@
-@clean @phantomjs
+@clean @phantomjs @filters
 Feature: Searches with the intitle filter
   Background:
     Given I am at a random page
 
-  @filters
   Scenario: intitle: only includes pages with the title
     When I search for intitle:catapult
     Then Catapult is in the search results
@@ -11,31 +10,40 @@
     But Two Words is not in the search results
     And there is no link to create a new page from the search result
 
-  @filters
   Scenario: intitle: can be combined with other text
     When I search for intitle:catapult amazing
     Then Amazing Catapult is the first search result
     And Two Words is not in the search results
 
-  @filters
   Scenario: -intitle: excludes pages with part of the title
     When I search for -intitle:amazing intitle:catapult
     Then Catapult is the first search result
     And Amazing Catapult is not in the search results
     And there is no link to create a new page from the search result
 
-  @filters
   Scenario: -intitle: doesn't highlight excluded title
     When I search for -intitle:catapult two words
     Then Two Words is the first search result
     And ffnonesenseword catapult pickles anotherword is the highlighted text 
of the first search result
 
-  @wildcards @filters
+  @wildcards
   Scenario: intitle: can take a wildcard
     When I search for intitle:catapul*
     Then Catapult is the first search result
 
-  @wildcards @filters @setup_main
+  @wildcards @setup_main
   Scenario: intitle: can take a wildcard and combine it with a regular wildcard
     When I search for intitle:catapul* amaz*
     Then Amazing Catapult is the first search result
+
+  Scenario: intitle: will accept a space after its :
+    When I search for intitle: catapult
+    Then Catapult is in the search results
+    And Amazing Catapult is in the search results
+    But Two Words is not in the search results
+    And there is no link to create a new page from the search result
+
+  Scenario: intitle: will accept a space after its : with quoted titles
+    When I search for intitle: "amazing catapult"
+    Then Amazing Catapult is the first search result
+    And Two Words is not in the search results

-- 
To view, visit https://gerrit.wikimedia.org/r/133195
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3cd9953d0407541a7f97c22bf13060f5f8743baa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: Manybubbles <never...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to