From 9adbbccad8d33e8dd0d52f545d4f0960bc27b186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 9 Nov 2021 22:33:59 +0100 Subject: [PATCH] Auto topic subscriptions disabled by default, enabled only for new users when out of beta Bug: T294398 Change-Id: I909caaebbb976624a16f15361d4ee232007ff506 --- extension.json | 2 +- includes/Hooks/PreferenceHooks.php | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/extension.json b/extension.json index 2cb754b62..aabaf264e 100644 --- a/extension.json +++ b/extension.json @@ -497,7 +497,7 @@ "discussiontools-replytool": 1, "discussiontools-sourcemodetoolbar": 1, "discussiontools-topicsubscription": 1, - "discussiontools-autotopicsub": 1, + "discussiontools-autotopicsub": 0, "discussiontools-abtest": "" }, "config": { diff --git a/includes/Hooks/PreferenceHooks.php b/includes/Hooks/PreferenceHooks.php index 5ed092f40..764de578e 100644 --- a/includes/Hooks/PreferenceHooks.php +++ b/includes/Hooks/PreferenceHooks.php @@ -201,10 +201,17 @@ class PreferenceHooks implements * @return bool|void True or no return value to continue or false to abort */ public function onLocalUserCreated( $user, $autocreated ) { - // We want new users to be created with email-subscriptions to our notifications enabled if ( !$autocreated ) { $userOptionsManager = MediaWikiServices::getInstance()->getUserOptionsManager(); + // We want new users to be created with email-subscriptions to our notifications enabled $userOptionsManager->setOption( $user, 'echo-subscriptions-email-dt-subscription', true ); + // The auto topic subscription feature is disabled by default for existing users, but + // we enable it for new users (T294398). + // This can only occur when the feature is available for everyone; when it's in beta, + // the new user won't have the beta enabled, so it'll never be available here. + if ( HookUtils::isFeatureAvailableToUser( $user, HookUtils::AUTOTOPICSUB ) ) { + $userOptionsManager->setOption( $user, 'discussiontools-' . HookUtils::AUTOTOPICSUB, 1 ); + } $user->saveSettings(); } }