jenkins-bot has submitted this change and it was merged. Change subject: Fix errors that look like OR OR OR OR ......................................................................
Fix errors that look like OR OR OR OR These are caused by us pulling phrase prefix queries into a, well, phrase prefix query so they don't get to participate in OR and AND. They didn't work before so its not _that_ bad that they don't work now. But they shouldn't throw an error. T94814 Change-Id: I5a77bc602469eef4c3595f448c22ce4d542da13d --- M includes/Search/Escaper.php M tests/browser/features/bad_syntax_api.feature M tests/browser/features/step_definitions/search_steps.rb 3 files changed, 13 insertions(+), 1 deletion(-) Approvals: Chad: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/Search/Escaper.php b/includes/Search/Escaper.php index 50c1a4c..9f89ca0 100644 --- a/includes/Search/Escaper.php +++ b/includes/Search/Escaper.php @@ -130,7 +130,7 @@ // Lowercase AND and OR when not surrounded on both sides by a term. // Lowercase NOT when it doesn't have a term after it. - $string = preg_replace_callback( '/^\s*(?:AND|OR)/u', + $string = preg_replace_callback( '/^|(AND|OR|NOT)\s*(?:AND|OR)/u', 'CirrusSearch\Search\Escaper::lowercaseMatched', $string ); $string = preg_replace_callback( '/(?:AND|OR|NOT)\s*$/u', 'CirrusSearch\Search\Escaper::lowercaseMatched', $string ); diff --git a/tests/browser/features/bad_syntax_api.feature b/tests/browser/features/bad_syntax_api.feature index 4a8e0f0..d4c5445 100644 --- a/tests/browser/features/bad_syntax_api.feature +++ b/tests/browser/features/bad_syntax_api.feature @@ -87,3 +87,12 @@ Scenario: Searching for idiographic whitespace returns no result When I api search for %idiographic_whitespace% Then the api warns text search is disabled + + @boolean_operators + Scenario Outline: ORs and ANDs around phrase prefixes finds the search terms + When I api search for "test catapul*" <operator> "test catapul*" <operator> "test catapul*" + Then there are no errors reported by the api + Examples: + | operator | + | AND | + | OR | diff --git a/tests/browser/features/step_definitions/search_steps.rb b/tests/browser/features/step_definitions/search_steps.rb index 88d00bf..04ba24d 100644 --- a/tests/browser/features/step_definitions/search_steps.rb +++ b/tests/browser/features/step_definitions/search_steps.rb @@ -362,6 +362,9 @@ Then(/this error is reported: (.+)$/) do |expected_error| on(SearchResultsPage).error_report_element.text.strip.should == expected_error.strip end +Then(/there are no errors reported by the api$/) do + @api_error.should be nil +end Then(/this error is reported by api: (.+)$/) do |expected_error| @api_error.code.should be == "srsearch-error" CGI.unescapeHTML(@api_error.info).should == expected_error.strip -- To view, visit https://gerrit.wikimedia.org/r/210536 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5a77bc602469eef4c3595f448c22ce4d542da13d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: wmf/1.26wmf5 Gerrit-Owner: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Chad <ch...@wikimedia.org> Gerrit-Reviewer: Manybubbles <never...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits