From 1c741d345009b520d7bfbf9d466aea1858b48d0c Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 14 Jan 2021 23:44:33 +0000 Subject: [PATCH] Preserve a user's beta preference when not in beta The tool may go in and out of beta as new features are release/graduated to opt-out. Users should only need to opt in to the beta feature once to get all future sub-features. Bug: T272071 Change-Id: If6834b7fc07fc7e84757dc5fdcea814cd0d65936 --- includes/Hooks.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/includes/Hooks.php b/includes/Hooks.php index c40edc761..b10af8a73 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -393,6 +393,19 @@ class Hooks { 'type' => 'api', ]; + $dtConfig = MediaWikiServices::getInstance()->getConfigFactory() + ->makeConfig( 'discussiontools' ); + if ( + !$dtConfig->get( 'DiscussionToolsEnable' ) || + !$dtConfig->get( 'DiscussionToolsBeta' ) + ) { + // When out of beta, preserve the user preference in case we + // bring back the beta feature for a new sub-feature. (T272071) + $preferences['discussiontools-betaenable'] = [ + 'type' => 'api' + ]; + } + $preferences['discussiontools-editmode'] = [ 'type' => 'api', 'validation-callback' => function ( $value ) {