Passing a string to ParserOutput::addModules()/addModuleStyles() is deprecated

Bug: T296123
Change-Id: If14866f76703aa62d33e197bb18a5eacde7a55c0
This commit is contained in:
C. Scott Ananian 2022-01-11 17:01:22 -05:00
parent fa5151d287
commit e0cece9bc6

View file

@ -138,7 +138,7 @@ class SyntaxHighlight {
// Register CSS
// TODO: Consider moving to a separate method so that public method
// highlight() can be used without needing to know the module name.
$parser->getOutput()->addModuleStyles( 'ext.pygments' );
$parser->getOutput()->addModuleStyles( [ 'ext.pygments' ] );
return $out;
}
@ -466,12 +466,12 @@ class SyntaxHighlight {
* @param int $revId
* @param ParserOptions $options
* @param bool $generateHtml
* @param ParserOutput &$output
* @param ParserOutput &$parserOutput
* @return bool
* @since MW 1.21
*/
public static function onContentGetParserOutput( Content $content, Title $title,
$revId, ParserOptions $options, $generateHtml, ParserOutput &$output
$revId, ParserOptions $options, $generateHtml, ParserOutput &$parserOutput
) {
global $wgTextModelsToParse;
@ -505,7 +505,7 @@ class SyntaxHighlight {
// Parse using the standard parser to get links etc. into the database, HTML is replaced below.
// We could do this using $content->fillParserOutput(), but alas it is 'protected'.
if ( in_array( $model, $wgTextModelsToParse ) ) {
$output = MediaWikiServices::getInstance()->getParser()
$parserOutput = MediaWikiServices::getInstance()->getParser()
->parse( $text, $title, $options, true, true, $revId );
}
@ -515,9 +515,9 @@ class SyntaxHighlight {
}
$out = $status->getValue();
$output->addModuleStyles( 'ext.pygments' );
$output->addModules( 'ext.pygments.linenumbers' );
$output->setText( $out );
$parserOutput->addModuleStyles( [ 'ext.pygments' ] );
$parserOutput->addModules( [ 'ext.pygments.linenumbers' ] );
$parserOutput->setText( $out );
// Inform MediaWiki that we have parsed this page and it shouldn't mess with it.
return false;