From 2060ead3915059511af29bacefbe0febcf775462 Mon Sep 17 00:00:00 2001 From: Jack Phoenix Date: Sat, 1 Aug 2020 21:12:31 +0300 Subject: [PATCH] Don't add the "minerva--history-page-action-enabled" class to for non-Minerva skins like MonoBook etc. Hooks are global, hence any and all skin-specific OutputPageBodyAttributes hooks need to check first that the correct skin (or skins) is used, otherwise the class or classes get applied for *all* skins when only one skin is supposed to be targeted. Also fixed a tiny code style issue in the same hook subscriber while at it. Change-Id: I626b0e050c614687b31f1ffbaea92e371dee4574 --- includes/MinervaHooks.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/includes/MinervaHooks.php b/includes/MinervaHooks.php index 0561b6c39..af8a0ed63 100644 --- a/includes/MinervaHooks.php +++ b/includes/MinervaHooks.php @@ -349,23 +349,22 @@ class MinervaHooks { public static function onOutputPageBodyAttributes( OutputPage $out, Skin $skin, &$bodyAttrs ) { $classes = $out->getProperty( 'bodyClassName' ); $skinOptions = MediaWikiServices::getInstance()->getService( 'Minerva.SkinOptions' ); + $isMinerva = $skin instanceof SkinMinerva; - if ( $skinOptions->get( SkinOptions::HISTORY_IN_PAGE_ACTIONS ) ) { + if ( $isMinerva && $skinOptions->get( SkinOptions::HISTORY_IN_PAGE_ACTIONS ) ) { // Class is used when page actions is modified to contain more elements $classes .= ' minerva--history-page-action-enabled'; - } - $isSimplifiedTalk = false; - if ( $skin instanceof SkinMinerva ) { - $isSimplifiedTalk = $skin->isSimplifiedTalkPageEnabled(); - } + if ( $isMinerva ) { + // phan doesn't realize that $skin can only be an instance of SkinMinerva without this: + '@phan-var SkinMinerva $skin'; + if ( $skin->isSimplifiedTalkPageEnabled() ) { + $classes .= ' skin-minerva--talk-simplified'; + } - if ( $isSimplifiedTalk ) { - $classes .= ' skin-minerva--talk-simplified'; + $bodyAttrs['class'] .= ' ' . $classes; } - - $bodyAttrs[ 'class' ] .= ' ' . $classes; } /**