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

Change subject: Act as a beta feature if so configured
......................................................................


Act as a beta feature if so configured

Add a configuration key, 'PopupsBetaFeature'. If true, Popups will act as a
beta-feature, and will depend on the BetaFeatures extension. Set to false by
default.

Bug: T88917
Bug: T88164
Change-Id: Ie4cc455fa6379dbc8ef700e4773bedfb49fcf813
---
M Popups.hooks.php
M Popups.php
2 files changed, 43 insertions(+), 6 deletions(-)

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



diff --git a/Popups.hooks.php b/Popups.hooks.php
index 64b2c78..f945689 100644
--- a/Popups.hooks.php
+++ b/Popups.hooks.php
@@ -18,10 +18,15 @@
  * @file
  * @ingroup extensions
  */
+use MediaWiki\Logger\LoggerFactory;
 
 class PopupsHooks {
        static function getPreferences( User $user, array &$prefs ){
                global $wgExtensionAssetsPath;
+
+               if ( self::getConfig()->get( 'PopupsBetaFeature' ) !== true ) {
+                       return;
+               }
 
                $prefs['popups'] = array(
                        'label-message' => 'popups-message',
@@ -36,6 +41,17 @@
                                'javascript' => true,
                        ),
                );
+       }
+
+       /**
+        * @return Config
+        */
+       public static function getConfig() {
+               static $config;
+               if ( !$config ) {
+                       $config = 
ConfigFactory::getDefaultInstance()->makeConfig( 'popups' );
+               }
+               return $config;
        }
 
        /**
@@ -108,13 +124,28 @@
        public static function onBeforePageDisplay( OutputPage &$out, Skin 
&$skin) {
                // Enable only if the user has turned it on in Beta 
Preferences, or BetaFeatures is not installed.
                // Will only be loaded if PageImages & TextExtracts extensions 
are installed.
-               if ( ( !class_exists( 'BetaFeatures' ) || 
BetaFeatures::isFeatureEnabled( $skin->getUser(), 'popups' ) )
-                       && defined( 'TEXT_EXTRACTS_INSTALLED' )
-                       && class_exists( 'ApiQueryPageImages' )
-               ) {
-                       $out->addModules( array( 'ext.popups' ) );
-                       $out->addModules( array( 'schema.Popups' ) );
+
+               if ( !defined( 'TEXT_EXTRACTS_INSTALLED' ) || !class_exists( 
'ApiQueryPageImages' ) ) {
+                       $logger = LoggerFactory::getInstance( 'popups' );
+                       $logger->error( 'Popups requires the PageImages and 
TextExtracts extensions.' );
+                       return true;
                }
+
+               if ( self::getConfig()->get( 'PopupsBetaFeature' ) === true ) {
+                       if ( !class_exists( 'BetaFeatures' ) ) {
+                               $logger = LoggerFactory::getInstance( 'popups' 
);
+                               $logger->error( 'PopupsMode cannot be used as a 
beta feature unless ' .
+                                                               'the 
BetaFeatures extension is present.' );
+                               return true;
+                       }
+                       if ( !BetaFeatures::isFeatureEnabled( $skin->getUser(), 
'popups' ) ) {
+                               return true;
+                       }
+               }
+
+               $out->addModules( array( 'ext.popups', 'schema.Popups' ) );
+
+               return true;
        }
 
        /**
diff --git a/Popups.php b/Popups.php
index f6d9cf3..e2a9312 100644
--- a/Popups.php
+++ b/Popups.php
@@ -33,6 +33,12 @@
        'license-name' => 'GPL-2.0+',
 );
 
+/**
+ * @var bool: Whether the extension should be enabled as an opt-in beta 
feature.
+ * If true, the BetaFeatures extension must be installed. False by default.
+ */
+$wgPopupsBetaFeature = false;
+
 $wgPopupsSurveyLink = false;
 $wgConfigRegistry['popups'] = 'GlobalVarConfig::newInstance';
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie4cc455fa6379dbc8ef700e4773bedfb49fcf813
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: Se4598 <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to