From c7cd5399e73945d418559d54faac3a0a3cacf1b4 Mon Sep 17 00:00:00 2001 From: Umherirrender Date: Tue, 17 Sep 2024 23:01:43 +0200 Subject: [PATCH] build: Use inline ignore for MediaWiki.Usage.DeprecatedGlobalVariables This avoids addition of new code with the deprecated global, or at least it gives extra attention on review when new code also uses the inline ignore Change-Id: I5c1bc5a1685c28f153d4fbe3525959930f54b557 --- .phpcs.xml | 1 - includes/CommentFormatter/CommentParser.php | 1 + includes/WikiMap/WikiMap.php | 1 + includes/actions/ActionEntryPoint.php | 2 ++ includes/api/ApiEditPage.php | 2 +- includes/api/ApiEntryPoint.php | 1 + includes/api/ApiParse.php | 1 + includes/context/RequestContext.php | 1 + includes/language/MessageCache.php | 1 + includes/linker/Linker.php | 1 + includes/specialpage/SpecialPageFactory.php | 2 +- tests/phpunit/MediaWikiIntegrationTestCase.php | 1 + 12 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.phpcs.xml b/.phpcs.xml index e83bacd6294..4a6694a0001 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -6,7 +6,6 @@ - diff --git a/includes/CommentFormatter/CommentParser.php b/includes/CommentFormatter/CommentParser.php index 685bbe15195..2083db28171 100644 --- a/includes/CommentFormatter/CommentParser.php +++ b/includes/CommentFormatter/CommentParser.php @@ -421,6 +421,7 @@ class CommentParser { // We should deprecate `null` as a valid value for // $selfLinkTarget to ensure that we can use it as // the title context for the external link. + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; $linkMarker = $this->addPageLink( $target, diff --git a/includes/WikiMap/WikiMap.php b/includes/WikiMap/WikiMap.php index c9fb22d58ec..51a56502f3a 100644 --- a/includes/WikiMap/WikiMap.php +++ b/includes/WikiMap/WikiMap.php @@ -149,6 +149,7 @@ class WikiMap { * @return string|false HTML link or false if the wiki was not found */ public static function makeForeignLink( $wikiID, $page, $text = null ) { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; if ( !$text ) { $text = $page; diff --git a/includes/actions/ActionEntryPoint.php b/includes/actions/ActionEntryPoint.php index 275b9c33680..44e29492b6b 100644 --- a/includes/actions/ActionEntryPoint.php +++ b/includes/actions/ActionEntryPoint.php @@ -86,6 +86,7 @@ class ActionEntryPoint extends MediaWikiEntryPoint { * Determine and send the response headers and body for this web request */ protected function execute() { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; // Get title from request parameters, @@ -361,6 +362,7 @@ class ActionEntryPoint extends MediaWikiEntryPoint { * @return void */ protected function performRequest() { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; $context = $this->getContext(); diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 7966484e87c..87686c1f3ef 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -488,7 +488,7 @@ class ApiEditPage extends ApiBase { // This is kind of a hack but it's the best we can do to make extensions work $requestArray += $this->getRequest()->getValues(); - // phpcs:ignore MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage + // phpcs:ignore MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage,MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle, $wgRequest; $req = new DerivativeRequest( $this->getRequest(), $requestArray, true ); diff --git a/includes/api/ApiEntryPoint.php b/includes/api/ApiEntryPoint.php index e95ca95474e..c9ae63aa179 100644 --- a/includes/api/ApiEntryPoint.php +++ b/includes/api/ApiEntryPoint.php @@ -82,6 +82,7 @@ class ApiEntryPoint extends MediaWikiEntryPoint { * the URL. */ protected function execute() { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; $context = $this->getContext(); diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 308c25810c4..501d08bfd24 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -253,6 +253,7 @@ class ApiParse extends ApiBase { // The parser needs $wgTitle to be set, apparently the // $title parameter in Parser::parse isn't enough *sigh* // TODO: Does this still need $wgTitle? + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; $format = null; diff --git a/includes/context/RequestContext.php b/includes/context/RequestContext.php index e97949222aa..8e0a328c672 100644 --- a/includes/context/RequestContext.php +++ b/includes/context/RequestContext.php @@ -210,6 +210,7 @@ class RequestContext implements IContextSource, MutableContext { */ public function getTitle() { if ( $this->title === null ) { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; # fallback to $wg till we can improve this $this->title = $wgTitle; $logger = LoggerFactory::getInstance( 'GlobalTitleFail' ); diff --git a/includes/language/MessageCache.php b/includes/language/MessageCache.php index ac5f82eabfe..f4b012332b6 100644 --- a/includes/language/MessageCache.php +++ b/includes/language/MessageCache.php @@ -1496,6 +1496,7 @@ class MessageCache implements LoggerAwareInterface { public function parse( $text, PageReference $page = null, $linestart = true, $interface = false, $language = null ) { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; if ( $this->inParser ) { diff --git a/includes/linker/Linker.php b/includes/linker/Linker.php index 2d938c00abc..b1237695d7c 100644 --- a/includes/linker/Linker.php +++ b/includes/linker/Linker.php @@ -1144,6 +1144,7 @@ class Linker { public static function makeExternalLink( $url, $text, $escape = true, $linktype = '', $attribs = [], $title = null ) { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle; $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer(); return $linkRenderer->makeExternalLink( diff --git a/includes/specialpage/SpecialPageFactory.php b/includes/specialpage/SpecialPageFactory.php index 8ef3abe2ccd..35b6cd5ce63 100644 --- a/includes/specialpage/SpecialPageFactory.php +++ b/includes/specialpage/SpecialPageFactory.php @@ -1746,7 +1746,7 @@ class SpecialPageFactory { public function capturePath( PageReference $page, IContextSource $context, LinkRenderer $linkRenderer = null ) { - // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser,MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgTitle, $wgOut, $wgRequest, $wgUser, $wgLang; $main = RequestContext::getMain(); diff --git a/tests/phpunit/MediaWikiIntegrationTestCase.php b/tests/phpunit/MediaWikiIntegrationTestCase.php index 93aa23bad23..8a24b03c5d4 100644 --- a/tests/phpunit/MediaWikiIntegrationTestCase.php +++ b/tests/phpunit/MediaWikiIntegrationTestCase.php @@ -510,6 +510,7 @@ abstract class MediaWikiIntegrationTestCase extends PHPUnit\Framework\TestCase { * reset services here. */ public static function resetNonServiceCaches() { + // phpcs:ignore MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle global $wgRequest, $wgJobClasses, $wgTitle; /* Prevent global wgTitle state from carrying over between test cases