Replace deprecated ParserOutput::getProperty

Change-Id: I9278120212bcd0c003af899ce9602c292edac947
This commit is contained in:
Umherirrender 2022-02-06 13:11:38 +01:00
parent 838ef90fe0
commit 6d3b7ce782

View file

@ -27,11 +27,19 @@ class Description2 {
*/
public static function setDescription( Parser $parser, $desc ) {
$parserOutput = $parser->getOutput();
if ( method_exists( $parserOutput, 'getPageProperty' ) ) {
// MW 1.38+
if ( $parserOutput->getPageProperty( 'description' ) !== false ) {
return;
}
$parserOutput->setPageProperty( 'description', $desc );
} else {
if ( $parserOutput->getProperty( 'description' ) !== false ) {
return;
}
$parserOutput->setProperty( 'description', $desc );
}
}
/**
* @link https://www.mediawiki.org/wiki/Manual:Hooks/ParserAfterTidy
@ -102,7 +110,12 @@ class Description2 {
*/
public static function onOutputPageParserOutput( OutputPage &$out, ParserOutput $parserOutput ) {
// Export the description from the main parser output into the OutputPage
if ( method_exists( $parserOutput, 'getPageProperty' ) ) {
// MW 1.38+
$description = $parserOutput->getPageProperty( 'description' );
} else {
$description = $parserOutput->getProperty( 'description' );
}
if ( $description !== false ) {
$out->addMeta( 'description', $description );
}