From 254ffbb55a3009e3b0626f72344ffcdafbb6ef98 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Thu, 31 Mar 2022 14:47:57 +1100 Subject: [PATCH] Don't set a user preference on new accounts by default Make it possible for Vector to be a non-default skin. Only set a user preference on newly created accounts if that has been explicitly requested in config. This should have no effect on WMF production. Change-Id: I52f62cf7eb78d2be4c59821a3cf29da9619602d9 --- includes/Hooks.php | 16 +++++++++------- skin.json | 4 ++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/includes/Hooks.php b/includes/Hooks.php index fa93ec346..d9d7a3cbf 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -449,13 +449,15 @@ class Hooks { */ public static function onLocalUserCreated( User $user, $isAutoCreated ) { $default = self::getConfig( Constants::CONFIG_KEY_DEFAULT_SKIN_VERSION_FOR_NEW_ACCOUNTS ); - $optionsManager = MediaWikiServices::getInstance()->getUserOptionsManager(); - $optionsManager->setOption( - $user, - Constants::PREF_KEY_SKIN, - $default === Constants::SKIN_VERSION_LEGACY ? - Constants::SKIN_NAME_LEGACY : Constants::SKIN_NAME_MODERN - ); + if ( $default ) { + $optionsManager = MediaWikiServices::getInstance()->getUserOptionsManager(); + $optionsManager->setOption( + $user, + Constants::PREF_KEY_SKIN, + $default === Constants::SKIN_VERSION_LEGACY ? + Constants::SKIN_NAME_LEGACY : Constants::SKIN_NAME_MODERN + ); + } } /** diff --git a/skin.json b/skin.json index b69189998..eba78e3c2 100644 --- a/skin.json +++ b/skin.json @@ -411,8 +411,8 @@ "description": "@var string:['2'|'1'] The version ('2' for latest, '1' for legacy) of the Vector skin to use when an existing user has not specified a preference. This configuration is not used for new accounts (see VectorDefaultSkinVersionForNewAccounts) and is impermanent. In the future, this field may contains versions such as \"beta\" which when specified and the BetaFeatures extension is installed, and the user is enrolled, the latest version is used otherwise legacy. The value is _not_ persisted." }, "VectorDefaultSkinVersionForNewAccounts": { - "value": "1", - "description": "@var string:['2'|'1'] The version ('2' for latest, '1' for legacy) of the Vector skin to **set** for newly created user accounts. **The value is persisted as a user preference.** This configuration is not used for preexisting accounts (see VectorDefaultSkinVersionForExistingAccounts) and only ever executed once at new account creation time." + "value": null, + "description": "@var string|null The version ('2' for latest, '1' for legacy) of the Vector skin to **set** for newly created user accounts. **The value is persisted as a user preference.** This configuration is not used for preexisting accounts (see VectorDefaultSkinVersionForExistingAccounts) and only ever executed once at new account creation time. If it is null, no user preference will be set." }, "VectorWvuiSearchOptions": { "value": {