diff --git a/includes/Hooks.php b/includes/Hooks.php index 46c42161..0d4f3eba 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -19,6 +19,7 @@ use MediaWiki\Cache\CacheKeyHelper; use MediaWiki\ChangeTags\Hook\ChangeTagsListActiveHook; use MediaWiki\ChangeTags\Hook\ListDefinedTagsHook; use MediaWiki\Extension\BetaFeatures\BetaFeatures; +use MediaWiki\Extension\DiscussionTools\Hooks as DiscussionToolsHooks; use MediaWiki\Extension\EventLogging\EventLogging; use MediaWiki\Hook\EditPage__attemptSave_afterHook; use MediaWiki\Hook\EditPage__attemptSaveHook; @@ -146,8 +147,11 @@ class Hooks implements 'mw_version' => MW_VERSION, ] + $data; - if ( $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' ) ) { - $data['bucket'] = $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' ); + $bucket = ExtensionRegistry::getInstance()->isLoaded( 'DiscussionTools' ) ? + // @phan-suppress-next-line PhanUndeclaredClassMethod + DiscussionToolsHooks\HookUtils::determineUserABTestBucket( $user ) : false; + if ( $bucket ) { + $data['bucket'] = $bucket; } if ( $user->isAnon() ) { @@ -194,7 +198,9 @@ class Hooks implements 'user_editcount' => $editCount ?: 0, ]; - $bucket = $this->userOptionsLookup->getOption( $user, 'discussiontools-abtest2' ); + $bucket = ExtensionRegistry::getInstance()->isLoaded( 'DiscussionTools' ) ? + // @phan-suppress-next-line PhanUndeclaredClassMethod + DiscussionToolsHooks\HookUtils::determineUserABTestBucket( $user ) : false; if ( $bucket ) { $data['bucket'] = $bucket; } diff --git a/modules/ext.wikiEditor.js b/modules/ext.wikiEditor.js index 23fc7fda..1ee1b8e5 100644 --- a/modules/ext.wikiEditor.js +++ b/modules/ext.wikiEditor.js @@ -48,24 +48,13 @@ }; } - function addABTestData( data, addToken ) { + function addABTestData( data ) { // DiscussionTools New Topic A/B test for logged out users if ( !mw.config.get( 'wgDiscussionToolsABTest' ) ) { return; } - if ( mw.user.isAnon() ) { - var tokenData = mw.storage.getObject( 'DTNewTopicABToken' ); - if ( !tokenData ) { - return; - } - var anonid = parseInt( tokenData.token.slice( 0, 8 ), 16 ); - data.bucket = anonid % 2 === 0 ? 'test' : 'control'; - if ( addToken ) { - // eslint-disable-next-line camelcase - data.anonymous_user_token = tokenData.token; - } - } else if ( mw.user.options.get( 'discussiontools-abtest2' ) ) { - data.bucket = mw.user.options.get( 'discussiontools-abtest2' ); + if ( mw.config.get( 'wgDiscussionToolsABTestBucket' ) ) { + data.bucket = mw.config.get( 'wgDiscussionToolsABTestBucket' ); } } @@ -104,7 +93,7 @@ data.user_class = 'IP'; } - addABTestData( data, true ); + addABTestData( data ); // Schema's kind of a mess of special properties if ( data.action === 'init' || data.action === 'abort' || data.action === 'saveFailure' ) {