Reset SkinOptions after logging out

Bug: T221137
Change-Id: I36ada157327b649900dbcee3917883fe8ee7687a
This commit is contained in:
jdlrobson 2019-08-01 13:15:19 -07:00 committed by Jdlrobson
parent 4efd72a879
commit 97f0e44e19
2 changed files with 33 additions and 2 deletions

View File

@ -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

View File

@ -93,6 +93,9 @@
"minerva": "GlobalVarConfig::newInstance"
},
"Hooks": {
"UserLogoutComplete": [
"MinervaHooks::onUserLogoutComplete"
],
"FetchChangesList": [
"MinervaHooks::onFetchChangesList"
],