Robmoen has uploaded a new change for review.

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

Change subject: Remove mobile.experiments as mediawiki.experiments is in core
......................................................................

Remove mobile.experiments as mediawiki.experiments is in core

Bug: T111287
Change-Id: I2cd0d95632be884db5cafd6d5b789e55c95c4609
---
M includes/Config.php
M includes/MobileFrontend.hooks.php
M includes/Resources.php
D includes/config/Experiments.php
M includes/skins/SkinMinerva.php
D resources/mobile.experiments/experiments.js
D tests/qunit/mobile.experiments/test_experiments.js
7 files changed, 0 insertions(+), 238 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/01/237501/1

diff --git a/includes/Config.php b/includes/Config.php
index 6c13fc9..64442c9 100644
--- a/includes/Config.php
+++ b/includes/Config.php
@@ -3,7 +3,6 @@
        require_once __DIR__ . "/config/Analytics.php";
        require_once __DIR__ . "/config/Editing.php";
        require_once __DIR__ . "/config/Experimental.php";
-       require_once __DIR__ . "/config/Experiments.php";
        require_once __DIR__ . "/config/Legacy.php";
        require_once __DIR__ . "/config/Nearby.php";
        require_once __DIR__ . "/config/Site.php";
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index a2ec58d..ed8b861 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -348,7 +348,6 @@
                // Get the licensing agreement that is displayed in the 
uploading interface.
                $wgMFUploadLicense = SkinMinerva::getLicense( 'upload' );
                $vars += array(
-                       'wgMFExperiments' => $config->get( 'MFExperiments' ),
                        'wgMFNearbyEndpoint' => $config->get( 
'MFNearbyEndpoint' ),
                        'wgMFThumbnailSizes' => array(
                                'tiny' =>  MobilePage::TINY_IMAGE_WIDTH,
diff --git a/includes/Resources.php b/includes/Resources.php
index 08f493e..3861be0 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -1769,14 +1769,6 @@
                        'mobile.toc',
                ),
        ),
-       'mobile.experiments' => $wgMFResourceFileModuleBoilerplate + array(
-               'dependencies' => array(
-                       'mobile.user',
-               ),
-               'scripts' => array(
-                       'resources/mobile.experiments/experiments.js',
-               ),
-       ),
 );
 
 $wgResourceModules = array_merge( $wgResourceModules,
diff --git a/includes/config/Experiments.php b/includes/config/Experiments.php
deleted file mode 100644
index 6f9c520..0000000
--- a/includes/config/Experiments.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-// Needs to be called within MediaWiki; not standalone
-if ( !defined( 'MEDIAWIKI' ) ) {
-       die( 'Not an entry point.' );
-}
-
-/**
- * @var array A set of experiments.
- *
- * Consider the following example:
- *
- * <code>
- * $wgMFExperiments = array(
- *     'wikigrok' => array(
- *         'enabled' => true,
- *         'buckets' => array(
- *             'control' => 0.33,
- *             'A' => 0.33,
- *             'B' => 0.33,
- *         ),
- *     ),
- * );
- * </code>
- *
- * The wikigrok experiment has three buckets: control, A, and B. The user has 
a 33% chance of being
- * being assigned to each bucket. Note well that if the experiment were 
disabled, then the user is
- * always assigned to the control bucket.
- */
-$wgMFExperiments = array();
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 5931cc3..97d9230 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -1023,12 +1023,6 @@
                                        $modules[] = 'mobile.newusers';
                                }
                        }
-
-                       $mfExperiments = $this->getMFConfig()->get( 
'MFExperiments' );
-
-                       if ( count( $mfExperiments ) > 0 ) {
-                               $modules[] = 'mobile.experiments';
-                       }
                }
 
                // TalkOverlay feature
diff --git a/resources/mobile.experiments/experiments.js 
b/resources/mobile.experiments/experiments.js
deleted file mode 100644
index b0cde2f..0000000
--- a/resources/mobile.experiments/experiments.js
+++ /dev/null
@@ -1,136 +0,0 @@
-( function ( M ) {
-
-       var CONTROL_BUCKET = 'control',
-               user = M.require( 'user' ),
-               MAX_INT32_UNSIGNED = 4294967295;
-
-       /**
-        * An implementation of Jenkins's one-at-a-time hash
-        * See <http://en.wikipedia.org/wiki/Jenkins_hash_function>
-        *
-        * @param {String} key String to hash.
-        * @return {Number} 32-bit integer.
-        * @ignore
-        *
-        * @author Ori Livneh <o...@wikimedia.org>
-        * @see http://jsbin.com/kejewi/4/watch?js,console
-        */
-       function hashString( key ) {
-               var hash = 0,
-                       i = key.length;
-
-               while ( i-- ) {
-                       hash += key.charCodeAt( i );
-                       hash += ( hash << 10 );
-                       hash ^= ( hash >> 6 );
-               }
-               hash += ( hash << 3 );
-               hash ^= ( hash >> 11 );
-               hash += ( hash << 15 );
-
-               return hash;
-       }
-
-       /**
-        * Gets the bucket for the experiment given the token.
-        *
-        * The name of the experiment and the user's token are hashed. The hash 
is converted to a number
-        * which is then used to assign the user to a bucket.
-        *
-        * Consider the following experiment configuration:
-        *
-        * ```
-        * {
-        *   enabled: true,
-        *   buckets: {
-        *     control: 0.5
-        *     A: 0.25,
-        *     B: 0.25
-        *   }
-        * }
-        * ```
-        *
-        * The experiment has three buckets: control, A, and B. The user has a 
50% chance of being
-        * assigned to the control bucket, and a 25% chance of being assigned 
to either the A or B
-        * buckets. If the experiment were disabled, then the user would always 
be assigned to the
-        * control bucket.
-        *
-        * This function is based on the deprecated `mw.user.bucket` function.
-        *
-        * @ignore
-        * @param {Object} experiments A map of experiment name to experiment 
definition
-        * @param {String} experiment
-        * @param {String} token
-        * @throws Error If the experiment hasn't been defined
-        * @returns {String}
-        */
-       function getBucketInternal( experiments, experiment, token ) {
-               var options,
-                       buckets,
-                       key,
-                       range = 0,
-                       hash,
-                       max,
-                       acc = 0;
-
-               if ( !experiments.hasOwnProperty( experiment ) ) {
-                       throw new Error( 'The experiment "' + experiment + '" 
hasn\'t been defined.' );
-               }
-
-               options = experiments[experiment];
-
-               if ( !options.enabled ) {
-                       return CONTROL_BUCKET;
-               }
-
-               buckets = options.buckets;
-
-               for ( key in buckets ) {
-                       range += buckets[key];
-               }
-
-               hash = hashString( experiment + ':' + token );
-               max = ( Math.abs( hash ) / MAX_INT32_UNSIGNED ) * range;
-
-               for ( key in buckets ) {
-                       acc += buckets[key];
-
-                       if ( max <= acc ) {
-                               return key;
-                       }
-               }
-       }
-
-       /**
-        * @class mw.mobileFrontend.experiments
-        * @singleton
-        */
-       M.define( 'experiments', {
-
-               /**
-                * Gets the bucket for the experiment.
-                *
-                * If the experiment is disabled or if the browser doesn't 
support local storage, then the
-                * user is always assigned to the "control" bucket.
-                *
-                * Defers to `user.getSessionId` to generate and persist the 
token.
-                *
-                * @param {String} experiment
-                * @throws Error If the experiment hasn't been defined in the 
`$wgMFExperiments`
-                *  configuration variable
-                * @returns {String}
-                */
-               getBucket: function ( experiment ) {
-                       var experiments = mw.config.get( 'wgMFExperiments' ) || 
{},
-                               token = user.getSessionId();
-
-                       // The browser doesn't support local storage? See 
`browser.supportsLocalStorage`.
-                       if ( token === '' ) {
-                               return CONTROL_BUCKET;
-                       }
-
-                       return getBucketInternal( experiments, experiment, 
token );
-               }
-       } );
-
-}( mw.mobileFrontend ) );
diff --git a/tests/qunit/mobile.experiments/test_experiments.js 
b/tests/qunit/mobile.experiments/test_experiments.js
deleted file mode 100644
index 7025e3d..0000000
--- a/tests/qunit/mobile.experiments/test_experiments.js
+++ /dev/null
@@ -1,57 +0,0 @@
-( function ( mw, M ) {
-
-       var user = M.require( 'user' );
-
-       QUnit.module( 'MobileFrontend Experiments', {
-               setup: function () {
-                       this.wgMFExperiments = {
-                               foo: {
-                                       enabled: true,
-                                       buckets: {
-                                               control: 50,
-                                               'wikigrok-version-a': 25,
-                                               'wikigrok-version-b': 25
-                                       }
-                               },
-                               bar: {
-                                       enabled: false,
-                                       buckets: {
-                                               control: 84,
-                                               'should-see-wikigrok-roulette': 
16
-                                       }
-                               }
-                       };
-                       mw.config.set( 'wgMFExperiments', this.wgMFExperiments 
);
-
-                       this.stub( user, 'getSessionId' ).returns( 'session-id' 
);
-
-                       this.experiments = M.require( 'experiments' );
-               }
-       } );
-
-       QUnit.test( 'it should throw when the experiment hasn\'t been defined', 
1, function ( assert ) {
-               assert.throws( function () {
-                       this.experiments.getBucket( 'baz' );
-               } );
-       } );
-
-       QUnit.test( 'it should always return "control" if the experiment has 
been defined as disabled', 1, function ( assert ) {
-               var bucket = this.experiments.getBucket( 'bar' );
-
-               assert.strictEqual( 'control', bucket );
-       } );
-
-       QUnit.test( 'it should always assign the user to the same bucket given 
the same token', 1, function ( assert ) {
-               assert.strictEqual(
-                       this.experiments.getBucket( 'foo' ),
-                       this.experiments.getBucket( 'foo' )
-               );
-       } );
-
-       QUnit.test( 'it should always return "control" if the browser doesn\'t 
support local storage', 1, function ( assert ) {
-               user.getSessionId.returns( '' );
-
-               assert.strictEqual( 'control', this.experiments.getBucket( 
'foo' ) );
-       } );
-
-}( mw, mw.mobileFrontend ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2cd0d95632be884db5cafd6d5b789e55c95c4609
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Robmoen <rm...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to