From 4bdae1c9d25fdea958aa45e29ad34dcd9696b420 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Mon, 30 Jul 2018 17:18:09 +0300 Subject: [PATCH] Convert remaining MagicWord:: calls to MagicWordFactory Bug: T200247 Depends-On: Ie061fe90f9b9eca0cbf7e8199d9ca325c464867a Change-Id: I49c507f3875e46a8e15fd2c28d61c17188aabffc --- includes/actions/InfoAction.php | 6 ++++-- includes/api/ApiQuerySiteinfo.php | 2 +- includes/content/WikitextContent.php | 4 +++- includes/content/WikitextContentHandler.php | 4 +++- includes/jobqueue/jobs/DoubleRedirectJob.php | 4 +++- tests/phpunit/includes/content/JavaScriptContentTest.php | 4 +++- tests/phpunit/includes/content/WikitextContentTest.php | 4 +++- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 98dfeb33cb..e77cdf77c8 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -209,12 +209,14 @@ class InfoAction extends FormlessAction { protected function pageInfo() { global $wgContLang; + $services = MediaWikiServices::getInstance(); + $user = $this->getUser(); $lang = $this->getLanguage(); $title = $this->getTitle(); $id = $title->getArticleID(); $config = $this->context->getConfig(); - $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); + $linkRenderer = $services->getLinkRenderer(); $pageCounts = $this->pageCounts( $this->page ); @@ -599,7 +601,7 @@ class InfoAction extends FormlessAction { ]; // Array of MagicWord objects - $magicWords = MagicWord::getDoubleUnderscoreArray(); + $magicWords = $services->getMagicWordFactory()->getDoubleUnderscoreArray(); // Array of magic word IDs $wordIDs = $magicWords->names; diff --git a/includes/api/ApiQuerySiteinfo.php b/includes/api/ApiQuerySiteinfo.php index 4b408fc481..7d4b55f1e0 100644 --- a/includes/api/ApiQuerySiteinfo.php +++ b/includes/api/ApiQuerySiteinfo.php @@ -808,7 +808,7 @@ class ApiQuerySiteinfo extends ApiQueryBase { } public function appendVariables( $property ) { - $variables = MagicWord::getVariableIDs(); + $variables = MediaWikiServices::getInstance()->getMagicWordFactory()->getVariableIDs(); ApiResult::setArrayType( $variables, 'BCarray' ); ApiResult::setIndexedTagName( $variables, 'v' ); diff --git a/includes/content/WikitextContent.php b/includes/content/WikitextContent.php index 5beef31b8c..21947d2061 100644 --- a/includes/content/WikitextContent.php +++ b/includes/content/WikitextContent.php @@ -25,6 +25,8 @@ * @author Daniel Kinzler */ +use MediaWiki\MediaWikiServices; + /** * Content object for wiki text pages. * @@ -182,7 +184,7 @@ class WikitextContent extends TextContent { return $this->redirectTargetAndText; } - $redir = MagicWord::get( 'redirect' ); + $redir = MediaWikiServices::getInstance()->getMagicWordFactory()->get( 'redirect' ); $text = ltrim( $this->getNativeData() ); if ( $redir->matchStartAndRemove( $text ) ) { // Extract the first link and see if it's usable diff --git a/includes/content/WikitextContentHandler.php b/includes/content/WikitextContentHandler.php index 9c26ae1587..ab157f55b3 100644 --- a/includes/content/WikitextContentHandler.php +++ b/includes/content/WikitextContentHandler.php @@ -23,6 +23,8 @@ * @ingroup Content */ +use MediaWiki\MediaWikiServices; + /** * Content handler for wiki text pages. * @@ -60,7 +62,7 @@ class WikitextContentHandler extends TextContentHandler { } } - $mwRedir = MagicWord::get( 'redirect' ); + $mwRedir = MediaWikiServices::getInstance()->getMagicWordFactory()->get( 'redirect' ); $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $optionalColon . $destination->getFullText() . ']]'; diff --git a/includes/jobqueue/jobs/DoubleRedirectJob.php b/includes/jobqueue/jobs/DoubleRedirectJob.php index 74c446fc3c..1bcbd30c97 100644 --- a/includes/jobqueue/jobs/DoubleRedirectJob.php +++ b/includes/jobqueue/jobs/DoubleRedirectJob.php @@ -21,6 +21,8 @@ * @ingroup JobQueue */ +use MediaWiki\MediaWikiServices; + /** * Job to fix double redirects after moving a page * @@ -116,7 +118,7 @@ class DoubleRedirectJob extends Job { } // Check for a suppression tag (used e.g. in periodically archived discussions) - $mw = MagicWord::get( 'staticredirect' ); + $mw = MediaWikiServices::getInstance()->getMagicWordFactory()->get( 'staticredirect' ); if ( $content->matchMagicWord( $mw ) ) { wfDebug( __METHOD__ . ": skipping: suppressed with __STATICREDIRECT__\n" ); diff --git a/tests/phpunit/includes/content/JavaScriptContentTest.php b/tests/phpunit/includes/content/JavaScriptContentTest.php index 823be6f795..9506c364c5 100644 --- a/tests/phpunit/includes/content/JavaScriptContentTest.php +++ b/tests/phpunit/includes/content/JavaScriptContentTest.php @@ -1,5 +1,7 @@ getMagicWordFactory()->get( "staticredirect" ); $content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" ); $this->assertFalse( diff --git a/tests/phpunit/includes/content/WikitextContentTest.php b/tests/phpunit/includes/content/WikitextContentTest.php index c78bc5bd9c..687c7e034c 100644 --- a/tests/phpunit/includes/content/WikitextContentTest.php +++ b/tests/phpunit/includes/content/WikitextContentTest.php @@ -1,5 +1,7 @@ getMagicWordFactory()->get( "staticredirect" ); $content = $this->newContent( "#REDIRECT [[FOO]]\n__STATICREDIRECT__" ); $this->assertTrue( $content->matchMagicWord( $mw ), "should have matched magic word" ); -- 2.20.1