Merge "Hygiene: Remove experiment-related code" into mpga

This commit is contained in:
jenkins-bot 2016-12-16 19:48:09 +00:00 committed by Gerrit Code Review
commit 7e64a87d7f
6 changed files with 3 additions and 81 deletions

View file

@ -92,14 +92,8 @@ class PopupsHooks {
}
$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 ' .
@ -160,29 +154,6 @@ class PopupsHooks {
public static function onResourceLoaderGetConfigVars( array &$vars ) {
$conf = self::getConfig();
$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 = self::getConfig();
$user = $out->getUser();
if ( $config->get( 'PopupsExperiment' ) ) {
$vars['wgPopupsExperimentIsBetaFeatureEnabled'] =
class_exists( 'BetaFeatures' ) && BetaFeatures::isFeatureEnabled( $user, 'popups' );
}
}
/**

View file

@ -28,9 +28,6 @@
"ResourceLoaderGetConfigVars": [
"PopupsHooks::onResourceLoaderGetConfigVars"
],
"MakeGlobalVariablesScript": [
"PopupsHooks::onMakeGlobalVariablesScript"
],
"GetPreferences": [
"PopupsHooks::onGetPreferences"
]
@ -49,7 +46,6 @@
"PopupsBetaFeature": false,
"@SchemaPopupsSamplingRate": "@var number: Sample rate for logging events to Schema:Popups.",
"SchemaPopupsSamplingRate": 0,
"PopupsExperiment": false,
"@PopupsHideOptInOnPreferencesPage": "@var bool: Whether the option to enable/disable Page Previews should be hidden on Preferences page. Please note if PopupsBetaFeature is set to true this option will be always hidden. False by default",
"PopupsHideOptInOnPreferencesPage": true,
"@PopupsOptInDefaultState" : "@var string:[enabled|disabled] Default Page Previews visibility",
@ -123,7 +119,6 @@
"popups-preview-footer-read"
],
"dependencies": [
"mediawiki.experiments",
"mediawiki.storage",
"mediawiki.Title",
"mediawiki.jqueryMsg",

View file

@ -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 );

View file

@ -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 {
/**
@ -51,27 +50,6 @@
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;
},
/**
* Gets the number of Page Previews that the user has seen.
*

View file

@ -14,9 +14,6 @@
},
sessionId: function () {
return '0123456789';
},
generateRandomSessionId: function () {
return '9876543210';
}
};
};

View file

@ -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 );