From 893290d4b46945913a075498c458ede2beda740e Mon Sep 17 00:00:00 2001 From: David Lynch Date: Fri, 17 Dec 2021 11:30:09 -0600 Subject: [PATCH] Ignore the beta feature setting when enrolling in the A/B test We realized that any change made to Special:Preferences will set the beta preference even if they didn't visit the beta tab, so we can't actually tell if manual intent was involved. As such, we'll enroll people regardless of their beta setting -- they can disable the feature through regular preferences if they want, and that'll be respected. Bug: T291307 Change-Id: I8c1cbf51060012e8e68af252da84944dfcc681d8 --- includes/Hooks/HookUtils.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/includes/Hooks/HookUtils.php b/includes/Hooks/HookUtils.php index 3ed061bf5..6eb2fb1a2 100644 --- a/includes/Hooks/HookUtils.php +++ b/includes/Hooks/HookUtils.php @@ -99,19 +99,20 @@ class HookUtils { } } + // Being in the "test" group for this feature means it's enabled. This + // overrules the wiki's beta feature setting. (However, a user who's + // in the control group can still bypass this and enable the feature + // normally.) + $abtest = static::determineUserABTestBucket( $user, $feature ); + if ( $abtest === 'test' ) { + return true; + } + // No feature-specific override found. if ( $dtConfig->get( 'DiscussionToolsBeta' ) ) { - $betaenabled = $optionsLookup->getOption( $user, 'discussiontools-betaenable', -1 ); - if ( $betaenabled !== -1 ) { - // betaenable doesn't have a default value, so we can check - // for it being unset like this. If the user has explicitly - // enabled or disabled it, we should immediately return that. - return (bool)$betaenabled; - } - // Otherwise, being in the "test" group for this feature means - // it's effectively beta-enabled. - return static::determineUserABTestBucket( $user, $feature ) === 'test'; + $betaenabled = $optionsLookup->getOption( $user, 'discussiontools-betaenable', 0 ); + return (bool)$betaenabled; } // Assume that if BetaFeature is turned off, or user has it enabled, that