Phuedx has uploaded a new change for review.

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

Change subject: Remove useful but unused helpers
......................................................................

Remove useful but unused helpers

Remove the following:

* assignToken script
* User class and supporting Bucket enumeration

Change-Id: Iddc2f377bca66fef9b52ea7f66d0dac8e38392dc
---
M GettingStarted.php
M Hooks.php
D resources/ext.gettingstarted.assignToken.js
D resources/ext.gettingstarted.bucket.js
D resources/ext.gettingstarted.user.js
D tests/qunit/ext.gettingstarted.user.test.js
6 files changed, 0 insertions(+), 236 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GettingStarted 
refs/changes/05/162005/1

diff --git a/GettingStarted.php b/GettingStarted.php
index ea8a6bf..e5fdd81 100644
--- a/GettingStarted.php
+++ b/GettingStarted.php
@@ -315,17 +315,6 @@
        'position' => 'top',
 ) + $gettingStartedModuleInfo;
 
-$wgResourceModules[ 'ext.gettingstarted.user' ] = array(
-       'scripts' => array(
-               'ext.gettingstarted.bucket.js',
-               'ext.gettingstarted.user.js',
-       ),
-       'dependencies' => array(
-               'mediawiki.user',
-               'jquery.cookie',
-       ),
-) + $gettingStartedModuleInfo;
-
 // Events for the Anonymous Edit Acquisition project.
 
 $wgResourceModules[ 'schema.SignupExpPageLinkClick' ] = array(
@@ -372,13 +361,6 @@
        'revision' => 9266317
 );
 
-$wgResourceModules[ 'ext.gettingstarted.assignToken' ] = array(
-       'scripts' => 'ext.gettingstarted.assignToken.js',
-       'dependencies' => array(
-               'ext.gettingstarted.user'
-       ),
-) + $gettingStartedModuleInfo;
-
 $wgDefaultUserOptions[ GettingStarted\Hooks::INTRO_OPTION ] = true;
 
 $wgHooks[ 'BeforePageDisplay' ][] = 
'GettingStarted\Hooks::onBeforePageDisplay';
@@ -390,7 +372,6 @@
 $wgHooks[ 'ResourceLoaderGetConfigVars' ][] = 
'GettingStarted\Hooks::onResourceLoaderGetConfigVars';
 $wgHooks[ 'GetPreferences' ][] = 'GettingStarted\Hooks::onGetPreferences';
 $wgHooks[ 'UserLogoutComplete'][] = 
'GettingStarted\Hooks::onUserLogoutComplete';
-$wgHooks[ 'ResourceLoaderTestModules' ][] = 
'GettingStarted\Hooks::onResourceLoaderTestModules';
 $wgHooks[ 'PersonalUrls' ][] = 'GettingStarted\Hooks::onPersonalUrls';
 $wgHooks[ 'UnitTestsList' ][] = 'GettingStarted\Hooks::onUnitTestsList';
 $wgExtensionFunctions[] = 'GettingStarted\Hooks::onSetup';
diff --git a/Hooks.php b/Hooks.php
index 7d9450b..79fe729 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -184,9 +184,6 @@
 
                $user = $out->getUser();
 
-               // Assign token; will support anonymous signup invite experiment
-               $out->addModules( 'ext.gettingstarted.assignToken' );
-
                if ( self::shouldLoadToolbar( $out, $user ) ) {
                        $request = $out->getRequest();
                        $taskName = self::getUnprefixedGettingStartedTask( 
$request, $out->getTitle() );
@@ -398,15 +395,6 @@
                }
                // Otherwise return true
                return true;
-       }
-
-       public static function onResourceLoaderTestModules( array 
&$testModules, \ResourceLoader &$resourceLoader ) {
-               $testModules[ 'qunit' ][ 'ext.gettingstarted.user.tests' ] = 
array(
-                       'scripts' => array( 
'tests/qunit/ext.gettingstarted.user.test.js' ),
-                       'dependencies' => array( 'ext.gettingstarted.user' ),
-                       'localBasePath' => __DIR__,
-                       'remoteExtPath' => 'GettingStarted',
-               );
        }
 
        /**
diff --git a/resources/ext.gettingstarted.assignToken.js 
b/resources/ext.gettingstarted.assignToken.js
deleted file mode 100644
index ee466ef..0000000
--- a/resources/ext.gettingstarted.assignToken.js
+++ /dev/null
@@ -1,16 +0,0 @@
-( function ( mw ) {
-       // Assign token to all users that visit an edit page.
-
-       var action = mw.config.get( 'wgAction' );
-
-       if ( action === 'edit' || action === 'submit' ) {
-               mw.gettingStarted.user.getToken();
-       } else {
-               // They could switch from wikitext to VE, but we don't need to 
register the VE hook
-               // if we already gave them a token.
-
-               mw.hook( 've.activationComplete' ).add( function () {
-                       mw.gettingStarted.user.getToken();
-               } );
-       }
-}( mediaWiki ) );
diff --git a/resources/ext.gettingstarted.bucket.js 
b/resources/ext.gettingstarted.bucket.js
deleted file mode 100644
index 3af8495..0000000
--- a/resources/ext.gettingstarted.bucket.js
+++ /dev/null
@@ -1,37 +0,0 @@
-( function ( mw ) {
-
-       'use strict';
-
-       mw.gettingStarted = mw.gettingStarted || {};
-
-       /**
-        * The buckets for the second iteraction of the Anonymous Editor 
Acquisition
-        * experiment.
-        *
-        * See 
https://www.mediawiki.org/wiki/Anonymous_editor_acquisition/Signup_invites_v2
-        *
-        * @enum
-        */
-       mw.gettingStarted.Bucket = {
-
-               /**
-                * The control bucket.
-                */
-               CONTROL: 'control',
-
-               /**
-                * The pre-edit v1 bucket.
-                *
-                * See 
https://www.mediawiki.org/wiki/Anonymous_editor_acquisition/Signup_invites_v2#Version_one
-                */
-               PRE_EDIT_V1: 'pre-edit v1',
-
-               /**
-                * The pre-edit v2 bucket.
-                *
-                * See 
https://www.mediawiki.org/wiki/Anonymous_editor_acquisition/Signup_invites_v2#Version_two
-                */
-               PRE_EDIT_V2: 'pre-edit v2'
-       };
-
-} ( mediaWiki ) );
diff --git a/resources/ext.gettingstarted.user.js 
b/resources/ext.gettingstarted.user.js
deleted file mode 100644
index 0c1d80a..0000000
--- a/resources/ext.gettingstarted.user.js
+++ /dev/null
@@ -1,74 +0,0 @@
-( function ( mw, $ ) {
-
-       'use strict';
-
-       var user,
-               // Cookie name can not have the word Token, to avoid serious 
Varnish caching problems.
-               tokenCookieName = mw.config.get( 'wgCookiePrefix' ) + 
'-gettingStartedUserId',
-               Bucket = mw.gettingStarted.Bucket;
-
-       /**
-        * The GettingStarted user API.
-        *
-        * This is currently used as part of the [Signup CTA experiment][0], 
which is
-        * part of the [Anonymous editor acquisition][1] research project.
-        *
-        * [0]: 
https://meta.wikimedia.org/wiki/Research:Anonymous_editor_acquisition/Signup_CTA_experiment
-        * [1]: 
https://meta.wikimedia.org/wiki/Research:Anonymous_editor_acquisition
-        *
-        * @class mw.gettingStarted.user
-        * @singleton
-        */
-       mw.gettingStarted.user = user = {
-
-               /**
-                * Gets the user's token from the "-gettingStartedUserId"
-                * cookie. If the cookie isn't set, then a token is generated,
-                * stored in the cookie for 90 days, and then returned.
-                *
-                * See `mw.user.generateRandomSessionId`.
-                *
-                * @return {string}
-                */
-               getToken: function () {
-                       var storedToken = $.cookie( tokenCookieName ),
-                               generatedToken;
-
-                       if ( storedToken ) {
-                               return storedToken;
-                       }
-
-                       generatedToken = mw.user.generateRandomSessionId();
-
-                       $.cookie( tokenCookieName, generatedToken, {
-                               expires: 90, // (days)
-                               path: '/'
-                       } );
-
-                       return generatedToken;
-               },
-
-               /**
-                * Gets the bucket that the user is in based on their token.
-                *
-                * Currently, the bucket corresponds to the variant of the
-                * experiement that the user will be shown: pre-edit v1,
-                * pre-edit v2, or control.
-                *
-                * @return {string}
-                */
-               getBucket: function () {
-                       var token = user.getToken(),
-                               lastCharacter = token.slice( -2, -1 );
-
-                       if ( lastCharacter <= 'J' ) {
-                               return Bucket.PRE_EDIT_V1;
-                       } else if ( lastCharacter > 'J' && lastCharacter <= 'd' 
) {
-                               return Bucket.PRE_EDIT_V2;
-                       } else {
-                               return Bucket.CONTROL;
-                       }
-               }
-       };
-
-} ( mediaWiki, jQuery ) );
diff --git a/tests/qunit/ext.gettingstarted.user.test.js 
b/tests/qunit/ext.gettingstarted.user.test.js
deleted file mode 100644
index 7510cc5..0000000
--- a/tests/qunit/ext.gettingstarted.user.test.js
+++ /dev/null
@@ -1,78 +0,0 @@
-( function ( QUnit, mw, $ ) {
-
-       'use strict';
-
-       var expectedTokenCookieName = mw.config.get( 'wgCookiePrefix' ) + 
'-gettingStartedUserId',
-               Bucket = mw.gettingStarted.Bucket;
-
-       QUnit.module( 'ext.gettingstarted.user.getToken', {
-               setup: function () {
-                       this.stub( mw.user, 'generateRandomSessionId' );
-                       mw.user.generateRandomSessionId.returns( '1234' );
-
-                       this.stub( $, 'cookie' );
-                       $.cookie.returns( null );
-               }
-       } );
-
-       QUnit.test( 'should try to get the "token" cookie', 1, function ( 
assert ) {
-               mw.gettingStarted.user.getToken();
-
-               assert.strictEqual( $.cookie.lastCall.args[ 0 ], 
expectedTokenCookieName );
-       } );
-
-       QUnit.test( 'should use the token from the "token" cookie when it is 
set', 1, function ( assert ) {
-               $.cookie.returns( '5678' );
-
-               assert.strictEqual( mw.gettingStarted.user.getToken(), '5678' );
-       } );
-
-       QUnit.test( 'should generate the token when the "token" cookie isn\'t 
set', 1, function ( assert ) {
-               assert.strictEqual( mw.gettingStarted.user.getToken(), '1234' );
-       } );
-
-       QUnit.test( 'should store the generated token when the cookie isn\'t 
set', 1, function ( assert ) {
-               mw.gettingStarted.user.getToken();
-
-               assert.deepEqual( $.cookie.lastCall.args, [
-                       expectedTokenCookieName,
-                       '1234',
-                       {
-                               expires: 90,
-                               path: '/'
-                       }
-               ] );
-       } );
-
-       QUnit.module( 'ext.gettingstarted.user.getBucket', {
-               setup: function () {
-                       this.stub( mw.gettingStarted.user, 'getToken' );
-               }
-       } );
-
-       $.each( [
-               {
-                       characters: '0123456789ABCDEFGHIJ',
-                       expectedBucket: Bucket.PRE_EDIT_V1
-               },
-               {
-                       characters: 'KLMNOPQRSTUVWXYZabcd',
-                       expectedBucket: Bucket.PRE_EDIT_V2
-               },
-               {
-                       characters: 'efghijklmnopqrstuvwxyz',
-                       expectedBucket: Bucket.CONTROL
-               }
-       ], function ( i, data ) {
-               QUnit.test( data.characters, data.characters.length, function ( 
assert ) {
-                       var j;
-
-                       for ( j = 0; j < data.characters.length; ++j ) {
-                               mw.gettingStarted.user.getToken.returns( 
data.characters[ j ] + '0' );
-
-                               assert.strictEqual( 
mw.gettingStarted.user.getBucket(), data.expectedBucket);
-                       }
-               } );
-       } );
-
-} ( QUnit, mediaWiki, jQuery ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iddc2f377bca66fef9b52ea7f66d0dac8e38392dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/GettingStarted
Gerrit-Branch: master
Gerrit-Owner: Phuedx <[email protected]>

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

Reply via email to