From 1b9ea4d1bf32df102b731ef8ec9aa807d3e88041 Mon Sep 17 00:00:00 2001 From: Derick Alangi Date: Thu, 2 May 2019 14:50:34 +0100 Subject: [PATCH] Avoid/Replace usage of deprecated `wfMemcKey()` function This global function was deprecated in 1.30 and is replaced with the use of `ObjectCache::getLocalClusterInstance()->makeKey()`. Change-Id: Ic08b53111be4374a973e08c2ed68224bfa922fa8 --- includes/cache/CacheHelper.php | 4 +++- includes/poolcounter/PoolWorkArticleView.php | 4 +++- tests/phpunit/includes/auth/AuthManagerTest.php | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/includes/cache/CacheHelper.php b/includes/cache/CacheHelper.php index ec6ce04000..d798ddbcb3 100644 --- a/includes/cache/CacheHelper.php +++ b/includes/cache/CacheHelper.php @@ -288,7 +288,9 @@ class CacheHelper implements ICacheHelper { throw new MWException( 'No cache key set, so cannot obtain or save the CacheHelper values.' ); } - return wfMemcKey( ...array_values( $this->cacheKey ) ); + return ObjectCache::getLocalClusterInstance()->makeKey( + ...array_values( $this->cacheKey ) + ); } /** diff --git a/includes/poolcounter/PoolWorkArticleView.php b/includes/poolcounter/PoolWorkArticleView.php index 2c9fbc8775..0abe1a5dde 100644 --- a/includes/poolcounter/PoolWorkArticleView.php +++ b/includes/poolcounter/PoolWorkArticleView.php @@ -114,7 +114,9 @@ class PoolWorkArticleView extends PoolCounterWork { $this->revision = $revision; $this->audience = $audience; $this->cacheKey = $this->parserCache->getKey( $page, $parserOptions ); - $keyPrefix = $this->cacheKey ?: wfMemcKey( 'articleview', 'missingcachekey' ); + $keyPrefix = $this->cacheKey ?: ObjectCache::getLocalClusterInstance()->makeKey( + 'articleview', 'missingcachekey' + ); parent::__construct( 'ArticleView', $keyPrefix . ':revid:' . $revid ); } diff --git a/tests/phpunit/includes/auth/AuthManagerTest.php b/tests/phpunit/includes/auth/AuthManagerTest.php index 209ed55fd4..5cf93c9e2b 100644 --- a/tests/phpunit/includes/auth/AuthManagerTest.php +++ b/tests/phpunit/includes/auth/AuthManagerTest.php @@ -2670,7 +2670,7 @@ class AuthManagerTest extends \MediaWikiTestCase { // Test backoff $cache = \ObjectCache::getLocalClusterInstance(); - $backoffKey = wfMemcKey( 'AuthManager', 'autocreate-failed', md5( $username ) ); + $backoffKey = $cache->makeKey( 'AuthManager', 'autocreate-failed', md5( $username ) ); $cache->set( $backoffKey, true ); $session->clear(); $user = \User::newFromName( $username ); @@ -2709,7 +2709,7 @@ class AuthManagerTest extends \MediaWikiTestCase { // Test addToDatabase throws an exception $cache = \ObjectCache::getLocalClusterInstance(); - $backoffKey = wfMemcKey( 'AuthManager', 'autocreate-failed', md5( $username ) ); + $backoffKey = $cache->makeKey( 'AuthManager', 'autocreate-failed', md5( $username ) ); $this->assertFalse( $cache->get( $backoffKey ), 'sanity check' ); $session->clear(); $user = $this->getMockBuilder( \User::class ) -- 2.20.1