jenkins-bot has submitted this change and it was merged.

Change subject: Provide sledgehammer to disable regular expression searches
......................................................................


Provide sledgehammer to disable regular expression searches

Sometimes they cause downtime and you want them gone for a bit.

Change-Id: Iee25718c2f3480f307726941af9e9f041a3fb53d
---
M CirrusSearch.php
M includes/Searcher.php
2 files changed, 11 insertions(+), 1 deletion(-)

Approvals:
  Chad: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CirrusSearch.php b/CirrusSearch.php
index ba0d988..c779a88 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -99,6 +99,11 @@
 // against.  It defaults to 10000 which seems like a reasonable compromize
 // to keep regexes fast while still producing good results.
 
+// Should CirrusSearch try to support regular expressions with insource:?
+// These can be really expensive, but mostly ok, especially if you have the
+// extra plugin installed. Sometimes they still cause issues though.
+$wgCirrusSearchEnableRegex = true;
+
 // By default, Cirrus will organize pages into one of two indexes (general or
 // content) based on whether a page is in a content namespace. This should
 // suffice for most wikis. This setting allows individual namespaces to be
diff --git a/includes/Searcher.php b/includes/Searcher.php
index 6535c80..952c98b 100644
--- a/includes/Searcher.php
+++ b/includes/Searcher.php
@@ -425,7 +425,12 @@
                        
'/(?<not>-)?insource:\/(?<pattern>(?:[^\\\\\/]|\\\\.)+)\/(?<insensitive>i)? ?/',
                        function ( $matches ) use ( $searcher, &$filters, 
&$notFilters, &$searchContainedSyntax, &$searchType, &$highlightSource ) {
                                global $wgLanguageCode,
-                                       $wgCirrusSearchWikimediaExtraPlugin;
+                                       $wgCirrusSearchWikimediaExtraPlugin,
+                                       $wgCirrusSearchEnableRegex;
+
+                               if ( !$wgCirrusSearchEnableRegex ) {
+                                       return;
+                               }
 
                                $searchContainedSyntax = true;
                                $searchType = 'regex';

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iee25718c2f3480f307726941af9e9f041a3fb53d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: wmf/1.25wmf5
Gerrit-Owner: Chad <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to