Add support for MediaWiki 1.38 (#73)

This commit is contained in:
Lens0021 2022-04-14 11:47:36 +09:00 committed by GitHub
parent 16a77dc880
commit e562c908e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 4 deletions

View file

@ -17,6 +17,7 @@ $cfg['exclude_analysis_directory_list'] = array_merge(
$cfg['suppress_issue_types'] = [ $cfg['suppress_issue_types'] = [
'PhanPluginMixedKeyNoKey', 'PhanPluginMixedKeyNoKey',
'SecurityCheck-LikelyFalsePositive', 'SecurityCheck-LikelyFalsePositive',
'UnusedPluginSuppression',
]; ];
$cfg['scalar_implicit_cast'] = true; $cfg['scalar_implicit_cast'] = true;

View file

@ -156,7 +156,7 @@ class PortableInfoboxParserTagController {
// (see: PortableInfoboxDataService.class.php) // (see: PortableInfoboxDataService.class.php)
$infoboxes = json_decode( $infoboxes = json_decode(
$parserOutput->getProperty( PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ), self::parserOutputGetPageProperty( $parserOutput, PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
true true
); );
@ -168,12 +168,33 @@ class PortableInfoboxParserTagController {
'metadata' => $raw->getMetadata() 'metadata' => $raw->getMetadata()
]; ];
$parserOutput->setProperty( self::parserOutputSetPageProperty(
$parserOutput,
PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME, PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME,
json_encode( $infoboxes ) 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 ) { private function handleError( $message ) {
$renderedValue = '<strong class="error"> ' . $message . '</strong>'; $renderedValue = '<strong class="error"> ' . $message . '</strong>';

View file

@ -52,7 +52,7 @@ class PortableInfoboxParsingHelper {
} }
return json_decode( return json_decode(
$parser->getOutput()->getProperty( PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ), self::parserOutputGetPageProperty( $parser->getOutput(), PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
true true
); );
} }
@ -68,11 +68,21 @@ class PortableInfoboxParsingHelper {
$parser->parse( $this->fetchArticleContent( $title ), $title, $parserOptions ); $parser->parse( $this->fetchArticleContent( $title ), $title, $parserOptions );
return json_decode( return json_decode(
$parser->getOutput()->getProperty( PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ), self::parserOutputGetPageProperty( $parser->getOutput(), PortableInfoboxDataService::INFOBOXES_PROPERTY_NAME ),
true 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 * @param Title $title
* *