Stop overwriting $cache in User::getCacheKey()
authorReedy <reedy@wikimedia.org>
Thu, 7 Feb 2019 03:30:57 +0000 (03:30 +0000)
committerReedy <reedy@wikimedia.org>
Thu, 7 Feb 2019 03:30:57 +0000 (03:30 +0000)
Replace a few deprecated function calls

Bug: T215483
Change-Id: I000b58d8bf67d9c1ea0123a7547b986e8ca69f25

includes/user/User.php

index f23c8ee..2d97b68 100644 (file)
@@ -496,7 +496,6 @@ class User implements IDBAccessObject, UserIdentity {
         * @return string
         */
        protected function getCacheKey( WANObjectCache $cache ) {
-               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
 
                return $cache->makeGlobalKey( 'user', 'id', $lbFactory->getLocalDomainID(), $this->mId );
@@ -520,7 +519,7 @@ class User implements IDBAccessObject, UserIdentity {
         * @since 1.25
         */
        protected function loadFromCache() {
-               $cache = ObjectCache::getMainWANInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                $data = $cache->getWithSetCallback(
                        $this->getCacheKey( $cache ),
                        $cache::TTL_HOUR,
@@ -2809,7 +2808,7 @@ class User implements IDBAccessObject, UserIdentity {
                        return;
                }
 
-               $cache = ObjectCache::getMainWANInstance();
+               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
                $key = $this->getCacheKey( $cache );
                if ( $mode === 'refresh' ) {
                        $cache->delete( $key, 1 );