From 0bb02c9c5710aa73dc209708d2cbe2cf496c3215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 29 Aug 2023 20:03:09 +0200 Subject: [PATCH] Only show notification after CentralAuth autologin on Vector 2022 This brings in CentralAuth for phan analysis, using config patch 8063720d68ee1d2db2c37c1ad55da3fbef688bce in CI. Bug: T345112 Change-Id: Iddd94b38f04a34dc18df8978c2bf45e8e204a85c --- .phan/config.php | 18 +++++++++++++++++- includes/CentralAuthHooks.php | 31 +++++++++++++++++++++++++++++++ skin.json | 7 +++++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 includes/CentralAuthHooks.php diff --git a/.phan/config.php b/.phan/config.php index 3f56d7dc7..1061f9c8b 100644 --- a/.phan/config.php +++ b/.phan/config.php @@ -16,4 +16,20 @@ * */ -return require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php'; +$cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php'; + +$cfg['directory_list'] = array_merge( + $cfg['directory_list'], + [ + '../../extensions/CentralAuth', + ] +); + +$cfg['exclude_analysis_directory_list'] = array_merge( + $cfg['exclude_analysis_directory_list'], + [ + '../../extensions/CentralAuth', + ] +); + +return $cfg; diff --git a/includes/CentralAuthHooks.php b/includes/CentralAuthHooks.php new file mode 100644 index 000000000..2de11e004 --- /dev/null +++ b/includes/CentralAuthHooks.php @@ -0,0 +1,31 @@ +userOptionsLookup = $userOptionsLookup; + } + + /** + * @inheritDoc + */ + public function onCentralAuthIsUIReloadRecommended( User $user, bool &$recommendReload ) { + if ( $this->userOptionsLookup->getDefaultOption( 'skin' ) === Constants::SKIN_NAME_MODERN ) { + // Vector 2022 does not support updating the UI without reloading the page (T345112) + $recommendReload = true; + } + } + +} diff --git a/skin.json b/skin.json index 1f693c651..d97b1c70c 100644 --- a/skin.json +++ b/skin.json @@ -170,11 +170,18 @@ "vector-toc-pinned": 1 }, "HookHandlers": { + "VectorCentralAuthHooks": { + "class": "MediaWiki\\Skins\\Vector\\CentralAuthHooks", + "services": [ + "UserOptionsLookup" + ] + }, "VectorHooks": { "class": "MediaWiki\\Skins\\Vector\\Hooks" } }, "Hooks": { + "CentralAuthIsUIReloadRecommended": "VectorCentralAuthHooks", "GetPreferences": "VectorHooks", "LocalUserCreated": "VectorHooks", "MakeGlobalVariablesScript": "VectorHooks",