diff --git a/includes/MinervaHooks.php b/includes/MinervaHooks.php index ece6f9c..44b2551 100644 --- a/includes/MinervaHooks.php +++ b/includes/MinervaHooks.php @@ -221,12 +221,12 @@ class MinervaHooks { } /** - * BeforePageDisplayMobile hook handler. + * Set the skin options for Minerva * * @param MobileContext $mobileContext * @param Skin $skin */ - public static function onRequestContextCreateSkinMobile( + private static function setMinervaSkinOptions( MobileContext $mobileContext, Skin $skin ) { // setSkinOptions is not available @@ -267,6 +267,34 @@ class MinervaHooks { } } + /** + * UserLogoutComplete hook handler. + * Resets skin options if a user logout occurs - this is necessary as the + * RequestContextCreateSkinMobile hook runs before the UserLogout hook. + * + * @param User $user + */ + public static function onUserLogoutComplete( User $user ) { + try { + $ctx = MediaWikiServices::getInstance()->getService( 'MobileFrontend.Context' ); + self::setMinervaSkinOptions( $ctx, $ctx->getSkin() ); + } catch ( Wikimedia\Services\NoSuchServiceException $ex ) { + // MobileFrontend not installed. Not important. + } + } + + /** + * BeforePageDisplayMobile hook handler. + * + * @param MobileContext $mobileContext + * @param Skin $skin + */ + public static function onRequestContextCreateSkinMobile( + MobileContext $mobileContext, Skin $skin + ) { + self::setMinervaSkinOptions( $mobileContext, $skin ); + } + /** * ResourceLoaderGetConfigVars hook handler. * Used for setting JS variables which are pulled in dynamically with RL diff --git a/skin.json b/skin.json index 11d9b7f..720aa07 100644 --- a/skin.json +++ b/skin.json @@ -93,6 +93,9 @@ "minerva": "GlobalVarConfig::newInstance" }, "Hooks": { + "UserLogoutComplete": [ + "MinervaHooks::onUserLogoutComplete" + ], "FetchChangesList": [ "MinervaHooks::onFetchChangesList" ],