Merge "Reset SkinOptions after logging out"

This commit is contained in:
jenkins-bot 2019-08-01 22:23:12 +00:00 committed by Gerrit Code Review
commit d8de612e0c
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"
],