From ff320d9e49f1e67c2b3dad42503b9f16ce089250 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Wed, 3 Jul 2019 13:17:16 +0100 Subject: [PATCH] objectcache: Hard deprecate `ObjectCache::getMainWANInstance()` This method was soft-deprecated in 1.28 and this patch cleans up usage (via object cache) in core and uses services. So, this is now fit for hard deprecation. Usage ===== https://codesearch.wmflabs.org/search/?q=getMainWANInstance&i=nope&files=&repos= Change-Id: I081a979ed6ed7acf37168a6d81ca4048aae5dd9c --- includes/objectcache/ObjectCache.php | 1 + tests/parser/ParserTestRunner.php | 2 +- .../includes/api/ApiQueryWatchlistRawIntegrationTest.php | 2 +- tests/phpunit/includes/linker/LinkRendererTest.php | 7 ++++--- tests/phpunit/includes/user/UserTest.php | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/objectcache/ObjectCache.php b/includes/objectcache/ObjectCache.php index e9853b176e..dae0c21878 100644 --- a/includes/objectcache/ObjectCache.php +++ b/includes/objectcache/ObjectCache.php @@ -359,6 +359,7 @@ class ObjectCache { * @deprecated Since 1.28 Use MediaWikiServices::getInstance()->getMainWANObjectCache() */ public static function getMainWANInstance() { + wfDeprecated( __METHOD__, '1.28' ); return MediaWikiServices::getInstance()->getMainWANObjectCache(); } diff --git a/tests/parser/ParserTestRunner.php b/tests/parser/ParserTestRunner.php index 7d46e834c1..f284b13f31 100644 --- a/tests/parser/ParserTestRunner.php +++ b/tests/parser/ParserTestRunner.php @@ -1656,7 +1656,7 @@ class ParserTestRunner { // Wipe WANObjectCache process cache, which is invalidated by article insertion // due to T144706 - ObjectCache::getMainWANInstance()->clearProcessCache(); + MediaWikiServices::getInstance()->getMainWANObjectCache()->clearProcessCache(); $this->executeSetupSnippets( $teardown ); } diff --git a/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php b/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php index 2af63c4983..c554fb3f49 100644 --- a/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php +++ b/tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php @@ -476,7 +476,7 @@ class ApiQueryWatchlistRawIntegrationTest extends ApiTestCase { new TitleValue( 1, 'ApiQueryWatchlistRawIntegrationTestPage1' ), ] ); - ObjectCache::getMainWANInstance()->clearProcessCache(); + MediaWikiServices::getInstance()->getMainWANObjectCache()->clearProcessCache(); $result = $this->doListWatchlistRawRequest( [ 'wrowner' => $otherUser->getName(), 'wrtoken' => '1234567890', diff --git a/tests/phpunit/includes/linker/LinkRendererTest.php b/tests/phpunit/includes/linker/LinkRendererTest.php index d4e1961efe..b26a247c80 100644 --- a/tests/phpunit/includes/linker/LinkRendererTest.php +++ b/tests/phpunit/includes/linker/LinkRendererTest.php @@ -138,9 +138,10 @@ class LinkRendererTest extends MediaWikiLangTestCase { } public function testGetLinkClasses() { - $wanCache = ObjectCache::getMainWANInstance(); - $titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter(); - $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo(); + $services = MediaWikiServices::getInstance(); + $wanCache = $services->getMainWANObjectCache(); + $titleFormatter = $services->getTitleFormatter(); + $nsInfo = $services->getNamespaceInfo(); $linkCache = new LinkCache( $titleFormatter, $wanCache, $nsInfo ); $foobarTitle = new TitleValue( NS_MAIN, 'FooBar' ); $redirectTitle = new TitleValue( NS_MAIN, 'Redirect' ); diff --git a/tests/phpunit/includes/user/UserTest.php b/tests/phpunit/includes/user/UserTest.php index 5a978f93ba..bb723158d6 100644 --- a/tests/phpunit/includes/user/UserTest.php +++ b/tests/phpunit/includes/user/UserTest.php @@ -1138,7 +1138,8 @@ class UserTest extends MediaWikiTestCase { $this->db->delete( 'actor', [ 'actor_user' => $id ], __METHOD__ ); User::purge( $domain, $id ); // Because WANObjectCache->delete() stupidly doesn't delete from the process cache. - ObjectCache::getMainWANInstance()->clearProcessCache(); + + MediaWikiServices::getInstance()->getMainWANObjectCache()->clearProcessCache(); $user = User::newFromId( $id ); $this->assertFalse( $user->getActorId() > 0, 'No Actor ID by default if none in database' ); -- 2.20.1