diff --git a/includes/Hooks.php b/includes/Hooks.php index 6f84db0e0..f7540c897 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -26,7 +26,6 @@ use Config; use ExtensionRegistry; use Hooks as MWHooks; use Html; -use MediaWiki\Hook\BeforePageDisplayHook; use MediaWiki\Hook\FetchChangesListHook; use MediaWiki\Hook\OutputPageBodyAttributesHook; use MediaWiki\Hook\UserLogoutCompleteHook; @@ -58,7 +57,6 @@ use Wikimedia\Services\NoSuchServiceException; * on() */ class Hooks implements - BeforePageDisplayHook, FetchChangesListHook, OutputPageBodyAttributesHook, ResourceLoaderGetConfigVarsHook, @@ -401,53 +399,6 @@ class Hooks implements } } - /** - * The Minerva skin loads message box styles differently from core, to - * reduce the amount of styles on the critical path. - * This adds message box styles to pages that need it, to avoid loading them - * on pages where they are not. - * - * @param OutputPage $out - * @param Skin $skin - */ - public function onBeforePageDisplay( $out, $skin ): void { - if ( $skin->getSkinName() === 'minerva' ) { - self::addMessageBoxStylesToPage( $out ); - } - } - - /** - * The Minerva skin loads message box styles differently from core, to - * reduce the amount of styles on the critical path. - * This adds message box styles to pages that need it, to avoid loading them - * on pages where they are not. - * The pages where they are needed are: - * - special pages - * - edit workflow (action=edit and action=submit) - * - when viewing old revisions - * - non-main namespaces for anon talk page messages - * - * @param OutputPage $out - */ - private static function addMessageBoxStylesToPage( OutputPage $out ) { - $request = $out->getRequest(); - $title = $out->getTitle(); - // Warning box styles are needed when reviewing old revisions - // and inside the fallback editor styles to action=edit page. - $requestAction = $request->getVal( 'action' ); - $viewAction = $requestAction === null || $requestAction === 'view'; - - if ( - $title->getNamespace() !== NS_MAIN || - $request->getText( 'oldid' ) || - !$viewAction - ) { - $out->addModuleStyles( [ - 'skins.minerva.messageBox.styles' - ] ); - } - } - /** * Modifies the `` element's attributes. * diff --git a/includes/Skins/SkinMinerva.php b/includes/Skins/SkinMinerva.php index d790fbf27..263d9ee99 100644 --- a/includes/Skins/SkinMinerva.php +++ b/includes/Skins/SkinMinerva.php @@ -1026,6 +1026,9 @@ class SkinMinerva extends SkinMustache { protected function getSkinStyles(): array { $title = $this->getTitle(); $skinOptions = $this->getSkinOptions(); + $request = $this->getRequest(); + $requestAction = $request->getVal( 'action' ); + $viewAction = $requestAction === null || $requestAction === 'view'; $styles = [ 'skins.minerva.base.styles', 'skins.minerva.content.styles.images', @@ -1036,6 +1039,17 @@ class SkinMinerva extends SkinMustache { 'skins.minerva.mainMenu.icons', 'skins.minerva.mainMenu.styles', ]; + + // Warning box styles are needed when reviewing old revisions + // and inside the fallback editor styles to action=edit page. + if ( + $title->getNamespace() !== NS_MAIN || + $request->getText( 'oldid' ) || + !$viewAction + ) { + $styles[] = 'skins.minerva.messageBox.styles'; + } + if ( $title->isMainPage() ) { $styles[] = 'skins.minerva.mainPage.styles'; } elseif ( $this->getUserPageHelper()->isUserPage() ) { diff --git a/skin.json b/skin.json index a60c2cad4..0ab6e555b 100644 --- a/skin.json +++ b/skin.json @@ -136,7 +136,6 @@ } }, "Hooks": { - "BeforePageDisplay": "main", "ResourceLoaderRegisterModules": "main", "SkinPageReadyConfig": "main", "UserLogoutComplete": "main",