Merge "Set ParserOutput 'injectTOC' based on Skin options for page views"

This commit is contained in:
jenkins-bot 2021-11-08 18:35:48 +00:00 committed by Gerrit Code Review
commit ba7ac9f655
2 changed files with 10 additions and 6 deletions

View file

@ -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'],

View file

@ -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 ) {