diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 3000632ed65..d52e75a238d 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -492,12 +492,12 @@ class ApiParse extends ApiBase { if ( isset( $prop['text'] ) ) { $skin = $context ? $context->getSkin() : null; - $options = $skin ? $skin->getOptions() : [ + $skinOptions = $skin ? $skin->getOptions() : [ 'toc' => true, ]; $result_array['text'] = $p_result->getText( [ 'allowTOC' => !$params['disabletoc'], - 'injectTOC' => $options['toc'], + 'injectTOC' => $skinOptions['toc'], 'enableSectionEditLinks' => !$params['disableeditsection'], 'wrapperDivClass' => $params['wrapoutputclass'], 'deduplicateStyles' => !$params['disablestylededuplication'], diff --git a/includes/page/Article.php b/includes/page/Article.php index 7a13f1f16a8..31898768e65 100644 --- a/includes/page/Article.php +++ b/includes/page/Article.php @@ -467,8 +467,14 @@ class Article implements Page { # Allow frames by default $outputPage->setPreventClickjacking( false ); + $skin = $outputPage->getSkin(); + $skinOptions = $skin->getOptions(); + $parserOptions = $this->getParserOptions(); - $poOptions = []; + $poOptions = [ + 'skin' => $skin, + 'injectTOC' => $skinOptions['toc'], + ]; # Allow extensions to vary parser options used for article rendering Hooks::runner()->onArticleParserOptions( $this, $parserOptions ); # Render printable version, use printable version cache @@ -748,9 +754,7 @@ class Article implements Page { # (and do this before OutputPage::addParserOutput() calls the # OutputPageParserOutput hook) $outputPage->setSections( $pOutput->getSections() ); - $outputPage->addParserOutput( $pOutput, $textOptions + [ - 'injectTOC' => true, - ] ); + $outputPage->addParserOutput( $pOutput, $textOptions ); # Preload timestamp to avoid a DB hit $cachedTimestamp = $pOutput->getTimestamp(); if ( $cachedTimestamp !== null ) {