EBernhardson has uploaded a new change for review.

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

Change subject: Allow switching completion suggester between default and beta 
feature
......................................................................

Allow switching completion suggester between default and beta feature

CirrusSearch was only setup to offer completion suggester as a
beta feature. This adds a flag to toggle beta beta feature and
using completion as the default prefix search.

Change-Id: I3ee645f003189b855ba1b4e623338e121499f9ba
---
M CirrusSearch.php
M includes/CirrusSearch.php
M includes/Hooks.php
3 files changed, 18 insertions(+), 7 deletions(-)


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

diff --git a/CirrusSearch.php b/CirrusSearch.php
index 33e6417..5ba4910 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -771,12 +771,16 @@
  * You have to build the completion suggester index with the maintenance script
  * updateSuggesterIndex.php. The suggester only supports queries to the main
  * namespace. PrefixSearch will be used in all other cases.
- *
- * NOTE: This is an experimental API
  */
 $wgCirrusSearchUseCompletionSuggester = false;
 
 /**
+ * Expose completion suggester as optional beta feature, rather than enabling
+ * for everyone. Requires $wgCirrusSearchUseCompletionSuggester = true.
+ */
+$wgCirrusSearchCompletionSuggesterBetaFeature = false;
+
+/**
  * Maximum number of results to ask from the elasticsearch completion
  * api, note that this value will be multiplied by fetch_limit_factor
  * set in Completion profiles (default to 2)
diff --git a/includes/CirrusSearch.php b/includes/CirrusSearch.php
index 695f3b8..fa800b0 100644
--- a/includes/CirrusSearch.php
+++ b/includes/CirrusSearch.php
@@ -547,8 +547,12 @@
                        return true;
                }
 
-               return class_exists( '\BetaFeatures' ) &&
-                       \BetaFeatures::isFeatureEnabled( $GLOBALS['wgUser'], 
'cirrussearch-completionsuggester' );
+               if ( $config->get( 'CirrusSearchCompletionSuggesterBetaFeature' 
) ) {
+                       return class_exists( '\BetaFeatures' ) &&
+                               \BetaFeatures::isFeatureEnabled( 
$GLOBALS['wgUser'], 'cirrussearch-completionsuggester' );
+               }
+
+               return true;
        }
 
        /**
diff --git a/includes/Hooks.php b/includes/Hooks.php
index f656afb..e9d5a21 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -610,8 +610,7 @@
         */
        public static function onResourceLoaderGetConfigVars( &$vars ) {
                global $wgCirrusSearchEnableSearchLogging,
-                       $wgCirrusSearchFeedbackLink,
-                       $wgCirrusSearchUseCompletionSuggester;
+                       $wgCirrusSearchFeedbackLink;
 
                $vars += array(
                        'wgCirrusSearchEnableSearchLogging' => 
$wgCirrusSearchEnableSearchLogging,
@@ -654,9 +653,13 @@
        public static function getBetaFeaturePreferences( User $user, &$pref ) {
                global $wgCirrusSearchUseCompletionSuggester,
                        $wgExtensionAssetsPath;
-               if ( !$wgCirrusSearchUseCompletionSuggester ) {
+
+               if ( !$wgCirrusSearchUseCompletionSuggester 
+                       || !$wgCirrusSearchCompletionSuggesterBetaFeature
+               ) {
                        return true;
                }
+
                $pref['cirrussearch-completionsuggester'] = array(
                        'label-message' => 
'cirrussearch-completionsuggester-pref',
                        'desc-message' => 
'cirrussearch-completionsuggester-desc',

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ee645f003189b855ba1b4e623338e121499f9ba
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>

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

Reply via email to