X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FOutputPage.php;h=e22f42ce213066c7c3c90671f2b238faebee4e2d;hb=15ca48adf291e1d0ab7d4c6d5c28fd54c4c994dd;hp=e71cf1866c604be60b83dd58d84733580efaa2c7;hpb=8f70b21991eadae944f1f3d7b69305d110e424b9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/OutputPage.php b/includes/OutputPage.php index e71cf1866c..e22f42ce21 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -285,9 +285,9 @@ class OutputPage extends ContextSource { private $mTarget = null; /** - * @var bool Whether parser output should contain table of contents + * @var bool Whether parser output contains a table of contents */ - private $mEnableTOC = true; + private $mEnableTOC = false; /** * @var bool Whether parser output should contain section edit links @@ -1839,6 +1839,14 @@ class OutputPage extends ContextSource { $outputPage = $this; Hooks::run( 'LanguageLinks', [ $this->getTitle(), &$this->mLanguageLinks, &$linkFlags ] ); Hooks::run( 'OutputPageParserOutput', [ &$outputPage, $parserOutput ] ); + + // This check must be after 'OutputPageParserOutput' runs in addParserOutputMetadata + // so that extensions may modify ParserOutput to toggle TOC. + // This cannot be moved to addParserOutputText because that is not + // called by EditPage for Preview. + if ( $parserOutput->getTOCEnabled() && $parserOutput->getTOCHTML() ) { + $this->mEnableTOC = true; + } } /** @@ -1879,7 +1887,6 @@ class OutputPage extends ContextSource { */ function addParserOutput( $parserOutput ) { $this->addParserOutputMetadata( $parserOutput ); - $parserOutput->setTOCEnabled( $this->mEnableTOC ); // Touch section edit links only if not previously disabled if ( $parserOutput->getEditSectionTokens() ) { @@ -2405,26 +2412,10 @@ class OutputPage extends ContextSource { } $sk = $this->getSkin(); - // add skin specific modules - $modules = $sk->getDefaultModules(); - - // Enforce various default modules for all pages and all skins - $coreModules = [ - // Keep this list as small as possible - 'site', - 'mediawiki.page.startup', - 'mediawiki.user', - ]; - - // Support for high-density display images if enabled - if ( $config->get( 'ResponsiveImages' ) ) { - $coreModules[] = 'mediawiki.hidpi'; - } - - $this->addModules( $coreModules ); - foreach ( $modules as $group ) { + foreach ( $sk->getDefaultModules() as $group ) { $this->addModules( $group ); } + MWDebug::addModules( $this ); // Avoid PHP 7.1 warning of passing $this by reference @@ -3017,7 +3008,7 @@ class OutputPage extends ContextSource { && $this->userCanPreview(); } - private function isUserCssPreview() { + protected function isUserCssPreview() { return $this->getConfig()->get( 'AllowUserCss' ) && $this->getTitle() && $this->getTitle()->isCssSubpage() @@ -3653,10 +3644,21 @@ class OutputPage extends ContextSource { [ 'name' => 'ResourceLoaderDynamicStyles', 'content' => '' ] ); + $separateReq = [ 'site.styles', 'user.styles' ]; foreach ( $this->rlExemptStyleModules as $group => $moduleNames ) { - $chunks[] = $this->makeResourceLoaderLink( $moduleNames, + // Combinable modules + $chunks[] = $this->makeResourceLoaderLink( + array_diff( $moduleNames, $separateReq ), ResourceLoaderModule::TYPE_STYLES ); + + foreach ( array_intersect( $moduleNames, $separateReq ) as $name ) { + // These require their own dedicated request in order to support "@import" + // syntax, which is incompatible with concatenation. (T147667, T37562) + $chunks[] = $this->makeResourceLoaderLink( $name, + ResourceLoaderModule::TYPE_STYLES + ); + } } return self::combineWrappedStrings( array_merge( $chunks, $append ) ); @@ -3918,15 +3920,7 @@ class OutputPage extends ContextSource { } /** - * Enables/disables TOC, doesn't override __NOTOC__ - * @param bool $flag - * @since 1.22 - */ - public function enableTOC( $flag = true ) { - $this->mEnableTOC = $flag; - } - - /** + * Whether the output has a table of contents * @return bool * @since 1.22 */