mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-23 15:57:10 +00:00
Add support for MediaWiki 1.38 (#73)
This commit is contained in:
parent
16a77dc880
commit
e562c908e8
|
@ -17,6 +17,7 @@ $cfg['exclude_analysis_directory_list'] = array_merge(
|
|||
$cfg['suppress_issue_types'] = [
|
||||
'PhanPluginMixedKeyNoKey',
|
||||
'SecurityCheck-LikelyFalsePositive',
|
||||
'UnusedPluginSuppression',
|
||||
];
|
||||
|
||||
$cfg['scalar_implicit_cast'] = true;
|
||||
|
|
|
@ -156,7 +156,7 @@ class PortableInfoboxParserTagController {
|
|||
// (see: PortableInfoboxDataService.class.php)
|
||||
|
||||
$infoboxes = json_decode(
|
||||
$parserOutput->getProperty( PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
|
||||
self::parserOutputGetPageProperty( $parserOutput, PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -168,12 +168,33 @@ class PortableInfoboxParserTagController {
|
|||
'metadata' => $raw->getMetadata()
|
||||
];
|
||||
|
||||
$parserOutput->setProperty(
|
||||
self::parserOutputSetPageProperty(
|
||||
$parserOutput,
|
||||
PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME,
|
||||
json_encode( $infoboxes )
|
||||
);
|
||||
}
|
||||
|
||||
private static function parserOutputGetPageProperty( \ParserOutput $parserOutput, string $name ) {
|
||||
if ( method_exists( \ParserOutput::class, 'getPageProperty' ) ) {
|
||||
// @phan-suppress-next-line PhanUndeclaredMethod since 1.38
|
||||
return $parserOutput->getPageProperty( $name );
|
||||
} else {
|
||||
// @phan-suppress-next-line PhanDeprecatedFunction deprecated since 1.38
|
||||
return $parserOutput->getProperty( $name );
|
||||
}
|
||||
}
|
||||
|
||||
private static function parserOutputSetPageProperty( \ParserOutput $parserOutput, string $name, $value ) {
|
||||
if ( method_exists( \ParserOutput::class, 'setPageProperty' ) ) {
|
||||
// @phan-suppress-next-line PhanUndeclaredMethod since 1.38
|
||||
$parserOutput->setPageProperty( $name, $value );
|
||||
} else {
|
||||
// @phan-suppress-next-line PhanDeprecatedFunction deprecated since 1.38
|
||||
$parserOutput->setProperty( $name, $value );
|
||||
}
|
||||
}
|
||||
|
||||
private function handleError( $message ) {
|
||||
$renderedValue = '<strong class="error"> ' . $message . '</strong>';
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class PortableInfoboxParsingHelper {
|
|||
}
|
||||
|
||||
return json_decode(
|
||||
$parser->getOutput()->getProperty( PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
|
||||
self::parserOutputGetPageProperty( $parser->getOutput(), PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
@ -68,11 +68,21 @@ class PortableInfoboxParsingHelper {
|
|||
$parser->parse( $this->fetchArticleContent( $title ), $title, $parserOptions );
|
||||
|
||||
return json_decode(
|
||||
$parser->getOutput()->getProperty( PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
|
||||
self::parserOutputGetPageProperty( $parser->getOutput(), PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
private static function parserOutputGetPageProperty( \ParserOutput $parserOutput, string $name ) {
|
||||
if ( method_exists( \ParserOutput::class, 'getPageProperty' ) ) {
|
||||
// @phan-suppress-next-line PhanUndeclaredMethod since 1.38
|
||||
return $parserOutput->getPageProperty( $name );
|
||||
} else {
|
||||
// @phan-suppress-next-line PhanDeprecatedFunction deprecated since 1.38
|
||||
return $parserOutput->getProperty( $name );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Title $title
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue