Merge "WikiPage: remove ::suppressTOC hack"
This commit is contained in:
commit
42d23476b9
5 changed files with 13 additions and 16 deletions
|
|
@ -27,6 +27,7 @@ use MediaWiki\Html\Html;
|
|||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
use MediaWiki\Parser\ParserOutputFlags;
|
||||
use MediaWiki\Title\Title;
|
||||
use Wikimedia\Minify\CSSMin;
|
||||
|
||||
|
|
@ -137,5 +138,8 @@ class CssContentHandler extends CodeContentHandler {
|
|||
|
||||
$output->clearWrapperDivClass();
|
||||
$output->setText( $html );
|
||||
// Suppress the TOC (T307691)
|
||||
$output->setOutputFlag( ParserOutputFlags::NO_TOC );
|
||||
$output->setSections( [] );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ use MediaWiki\Html\Html;
|
|||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use MediaWiki\Parser\ParserOutput;
|
||||
use MediaWiki\Parser\ParserOutputFlags;
|
||||
use MediaWiki\Title\Title;
|
||||
|
||||
/**
|
||||
|
|
@ -155,5 +156,8 @@ class JavaScriptContentHandler extends CodeContentHandler {
|
|||
|
||||
$output->clearWrapperDivClass();
|
||||
$output->setText( $html );
|
||||
// Suppress the TOC (T307691)
|
||||
$output->setOutputFlag( ParserOutputFlags::NO_TOC );
|
||||
$output->setSections( [] );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1886,16 +1886,6 @@ class WikiPage implements Page, IDBAccessObject, PageRecord {
|
|||
// we don't need special cases like this one, but see T313455.
|
||||
$options->disableContentConversion();
|
||||
}
|
||||
if ( $contentModel !== CONTENT_MODEL_WIKITEXT ) {
|
||||
$textModelsToParse = MediaWikiServices::getInstance()->getMainConfig()->get(
|
||||
MainConfigNames::TextModelsToParse );
|
||||
if ( in_array( $contentModel, $textModelsToParse, true ) ) {
|
||||
// @todo Content model should have a means to tweak options, so
|
||||
// we don't need special cases like this one. (T313455)
|
||||
// ( See TextContentHandler::fillParserOutput() )
|
||||
$options->setSuppressTOC(); # T307691
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -815,8 +815,11 @@ class ParserOptions {
|
|||
* other metadata generated (like the table of contents).
|
||||
* @see T307691
|
||||
* @since 1.39
|
||||
* @deprecated since 1.42; just clear the metadata in the final
|
||||
* parser output
|
||||
*/
|
||||
public function setSuppressTOC() {
|
||||
wfDeprecated( __METHOD__, '1.42' );
|
||||
$this->setOption( 'suppressTOC', true );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -858,18 +858,14 @@ class WikiPageDbTest extends MediaWikiLangTestCase {
|
|||
yield [
|
||||
NS_MAIN, 'JavaScript Test', CONTENT_MODEL_JAVASCRIPT, 'canonical',
|
||||
static function () {
|
||||
$po = ParserOptions::newFromAnon();
|
||||
$po->setSuppressTOC();
|
||||
return $po;
|
||||
return ParserOptions::newFromAnon();
|
||||
},
|
||||
];
|
||||
// CSS should have Table Of Contents suppressed
|
||||
yield [
|
||||
NS_MAIN, 'CSS Test', CONTENT_MODEL_CSS, 'canonical',
|
||||
static function () {
|
||||
$po = ParserOptions::newFromAnon();
|
||||
$po->setSuppressTOC();
|
||||
return $po;
|
||||
return ParserOptions::newFromAnon();
|
||||
},
|
||||
];
|
||||
// Language Conversion tables have content conversion disabled
|
||||
|
|
|
|||
Loading…
Reference in a new issue