From 9f4f4301ccf6935e98e7a750a43f554ee427e6d8 Mon Sep 17 00:00:00 2001 From: Umherirrender <umherirrender_de.wp@web.de> Date: Sat, 19 Dec 2020 20:07:50 +0100 Subject: [PATCH] Avoid wfMessage in special page Use self::msg instead to avoid global state Change-Id: I9a9af6ff854fdd94929d06ea270c044320f62cab --- .phpcs.xml | 1 - src/SpecialMathWikibase.php | 8 ++++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index 5e197436c..85b76d828 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -5,7 +5,6 @@ <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" /> <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" /> <exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" /> - <exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" /> <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" /> </rule> <file>.</file> diff --git a/src/SpecialMathWikibase.php b/src/SpecialMathWikibase.php index 97859dd47..cf191e9fb 100644 --- a/src/SpecialMathWikibase.php +++ b/src/SpecialMathWikibase.php @@ -37,7 +37,7 @@ class SpecialMathWikibase extends SpecialPage { $this->getPlainText( 'math-wikibase-special-error-header' ) ); $out->addHTML( - wfMessage( 'math-wikibase-special-error-no-wikibase' )->inContentLanguage()->parse() + $this->msg( 'math-wikibase-special-error-no-wikibase' )->inContentLanguage()->parse() ); return; } @@ -122,14 +122,14 @@ class SpecialMathWikibase extends SpecialPage { if ( $e instanceof InvalidArgumentException ) { $this->logger->warning( "An invalid ID was specified. Reason: " . $e->getMessage() ); $this->getOutput()->addHTML( - wfMessage( 'math-wikibase-special-error-invalid-argument' )->inContentLanguage()->parse() + $this->msg( 'math-wikibase-special-error-invalid-argument' )->inContentLanguage()->parse() ); } else { $this->logger->error( "An unknown error occurred while fetching data from Wikibase.", [ 'exception' => $e ] ); $this->getOutput()->addHTML( - wfMessage( 'math-wikibase-special-error-unknown' )->inContentLanguage()->parse() + $this->msg( 'math-wikibase-special-error-unknown' )->inContentLanguage()->parse() ); } } @@ -140,7 +140,7 @@ class SpecialMathWikibase extends SpecialPage { * @return string the plain text in current content language */ private function getPlainText( $key ) { - return wfMessage( $key )->inContentLanguage()->plain(); + return $this->msg( $key )->inContentLanguage()->plain(); } /**