objectcache: Hard deprecate `ObjectCache::getMainWANInstance()`
authorDerick Alangi <alangiderick@gmail.com>
Wed, 3 Jul 2019 12:17:16 +0000 (13:17 +0100)
committerD3r1ck01 <xsavitar.wiki@aol.com>
Tue, 9 Jul 2019 09:29:57 +0000 (09:29 +0000)
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
tests/parser/ParserTestRunner.php
tests/phpunit/includes/api/ApiQueryWatchlistRawIntegrationTest.php
tests/phpunit/includes/linker/LinkRendererTest.php
tests/phpunit/includes/user/UserTest.php

index e9853b1..dae0c21 100644 (file)
@@ -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();
        }
 
index 7d46e83..f284b13 100644 (file)
@@ -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 );
        }
index 2af63c4..c554fb3 100644 (file)
@@ -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',
index d4e1961..b26a247 100644 (file)
@@ -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' );
index 5a978f9..bb72315 100644 (file)
@@ -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' );