Phuedx has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/327195 )

Change subject: Hygiene: Remove experiment-related code
......................................................................

Hygiene: Remove experiment-related code

Changes:
* Remove $wgPopupsExperiment and $wgPopupsExperimentConfig config
  variables.
* Remove $wgPopupsExperimentIsBetaFeatureEnabled client-side config
  variable.
* Remove MakeGlobalVariablesScript hook handler as it's redundant.

Bug: T152687
Change-Id: Id25cd7c16da14b7ce9bad502565de9ff6d29434e
---
M Popups.hooks.php
M extension.json
M resources/ext.popups/boot.js
M resources/ext.popups/userSettings.js
M tests/qunit/ext.popups/stubs/user.js
M tests/qunit/ext.popups/userSettings.test.js
6 files changed, 4 insertions(+), 82 deletions(-)


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

diff --git a/Popups.hooks.php b/Popups.hooks.php
index 810f515..3706363 100644
--- a/Popups.hooks.php
+++ b/Popups.hooks.php
@@ -64,14 +64,8 @@
                }
 
                $config = self::getConfig();
-               $isExperimentEnabled = $config->get( 'PopupsExperiment' );
 
-               if (
-                       // If Popups are enabled as an experiment, then bypass 
checking whether the user has enabled
-                       // it as a beta feature.
-                       !$isExperimentEnabled &&
-                       $config->get( 'PopupsBetaFeature' ) === true
-               ) {
+               if ( $config->get( 'PopupsBetaFeature' ) === true ) {
                        if ( !class_exists( 'BetaFeatures' ) ) {
                                $logger = LoggerFactory::getInstance( 'popups' 
);
                                $logger->error( 'PopupsMode cannot be used as a 
beta feature unless ' .
@@ -131,28 +125,5 @@
        public static function onResourceLoaderGetConfigVars( array &$vars ) {
                $conf = ConfigFactory::getDefaultInstance()->makeConfig( 
'popups' );
                $vars['wgPopupsSchemaPopupsSamplingRate'] = $conf->get( 
'SchemaPopupsSamplingRate' );
-
-               if ( $conf->get( 'PopupsExperiment' ) ) {
-                       $vars['wgPopupsExperiment'] = true;
-                       $vars['wgPopupsExperimentConfig'] = $conf->get( 
'PopupsExperimentConfig' );
-               }
-       }
-
-       /**
-        * MakeGlobalVariablesScript hook handler.
-        *
-        * @see 
https://www.mediawiki.org/wiki/Manual:Hooks/MakeGlobalVariablesScript
-        *
-        * @param array $vars
-        * @param OutputPage $out
-        */
-       public static function onMakeGlobalVariablesScript( array &$vars, 
OutputPage $out ) {
-               $config = ConfigFactory::getDefaultInstance()->makeConfig( 
'popups' );
-               $user = $out->getUser();
-
-               if ( $config->get( 'PopupsExperiment' ) ) {
-                       $vars['wgPopupsExperimentIsBetaFeatureEnabled'] =
-                               class_exists( 'BetaFeatures' ) && 
BetaFeatures::isFeatureEnabled( $user, 'popups' );
-               }
        }
 }
diff --git a/extension.json b/extension.json
index 777cb03..c313c17 100644
--- a/extension.json
+++ b/extension.json
@@ -26,9 +26,6 @@
                ],
                "ResourceLoaderGetConfigVars": [
                        "PopupsHooks::onResourceLoaderGetConfigVars"
-               ],
-               "MakeGlobalVariablesScript": [
-                       "PopupsHooks::onMakeGlobalVariablesScript"
                ]
        },
        "MessagesDirs": {
@@ -43,8 +40,7 @@
                "@PopupsBetaFeature": "@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.",
                "PopupsBetaFeature": false,
                "@SchemaPopupsSamplingRate": "@var number: Sample rate for 
logging events to Schema:Popups.",
-               "SchemaPopupsSamplingRate": 0,
-               "PopupsExperiment": false
+               "SchemaPopupsSamplingRate": 0
        },
        "ResourceModules": {
                "ext.popups.images": {
@@ -114,7 +110,6 @@
                                "popups-preview-footer-read"
                        ],
                        "dependencies": [
-                               "mediawiki.experiments",
                                "mediawiki.storage",
                                "mediawiki.Title",
                                "mediawiki.jqueryMsg",
diff --git a/resources/ext.popups/boot.js b/resources/ext.popups/boot.js
index c171953..9184371 100644
--- a/resources/ext.popups/boot.js
+++ b/resources/ext.popups/boot.js
@@ -90,7 +90,7 @@
                        isEnabled,
                        schema;
 
-               userSettings = mw.popups.createUserSettings( mw.storage, 
mw.user );
+               userSettings = mw.popups.createUserSettings( mw.storage );
                settingsDialog = mw.popups.createSettingsDialogRenderer();
                schema = mw.popups.createSchema( mw.config, window );
 
diff --git a/resources/ext.popups/userSettings.js 
b/resources/ext.popups/userSettings.js
index 47c4aea..88c60ca 100644
--- a/resources/ext.popups/userSettings.js
+++ b/resources/ext.popups/userSettings.js
@@ -12,11 +12,10 @@
         * encapsulate all interactions with the given User Agent's storage.
         *
         * @param {mw.storage} storage The `mw.storage` singleton instance
-        * @param {mw.user} user The `mw.user` singleton instance
         *
         * @return {ext.popups.UserSettings}
         */
-       mw.popups.createUserSettings = function ( storage, user ) {
+       mw.popups.createUserSettings = function ( storage ) {
                return {
 
                        /**
@@ -49,27 +48,6 @@
                         */
                        hasIsEnabled: function () {
                                return storage.get( IS_ENABLED_KEY, undefined ) 
!== undefined;
-                       },
-
-                       /**
-                        * Gets the user's Page Previews token.
-                        *
-                        * If the storage doesn't contain a token, then one is 
generated and
-                        * persisted to the storage before being returned.
-                        *
-                        * @return {String}
-                        */
-                       getToken: function () {
-                               var key = 'PopupsExperimentID',
-                                       id = storage.get( key );
-
-                               if ( !id ) {
-                                       id = user.generateRandomSessionId();
-
-                                       storage.set( key, id );
-                               }
-
-                               return id;
                        },
 
                        /**
diff --git a/tests/qunit/ext.popups/stubs/user.js 
b/tests/qunit/ext.popups/stubs/user.js
index a7da294..0377a9d 100644
--- a/tests/qunit/ext.popups/stubs/user.js
+++ b/tests/qunit/ext.popups/stubs/user.js
@@ -14,9 +14,6 @@
                        },
                        sessionId: function () {
                                return '0123456789';
-                       },
-                       generateRandomSessionId: function () {
-                               return '9876543210';
                        }
                };
        };
diff --git a/tests/qunit/ext.popups/userSettings.test.js 
b/tests/qunit/ext.popups/userSettings.test.js
index 0e2eb77..63c23f7 100644
--- a/tests/qunit/ext.popups/userSettings.test.js
+++ b/tests/qunit/ext.popups/userSettings.test.js
@@ -41,25 +41,6 @@
                );
        } );
 
-       QUnit.test( '#getToken', 2, function ( assert ) {
-               var token = this.userSettings.getToken();
-
-               assert.ok(
-                       token,
-                       '#getToken should return a token even if the storage is 
empty.'
-               );
-
-               assert.equal(
-                       this.storage.get( 'PopupsExperimentID' ),
-                       token,
-                       '#getToken persists the token in the storage 
transparently.'
-               );
-       } );
-
-       QUnit.test( '#getToken should always return the same token', 1, 
function ( assert ) {
-               assert.equal( this.userSettings.getToken(), 
this.userSettings.getToken() );
-       } );
-
        QUnit.test( '#getPreviewCount should return the count as a number', 
function ( assert ) {
                assert.expect( 3 );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id25cd7c16da14b7ce9bad502565de9ff6d29434e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: mpga
Gerrit-Owner: Phuedx <[email protected]>

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

Reply via email to