From 3e4f40851a138326a25006b8aa27b1c3bb3a06aa Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 23 May 2017 20:36:53 -0700 Subject: [PATCH] InfoAction: Avoid deprecated wfMemcKey() And the deprecated ObjectCache::getMainWANInstance() while we're at it. Change-Id: Id7bb6a8c3e8269345e054d2c2bf202304b74c3cf --- includes/actions/InfoAction.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index df7afca945..0f13b17a5a 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -73,8 +73,9 @@ class InfoAction extends FormlessAction { $revid = $revision ? $revision->getId() : null; } if ( $revid !== null ) { - $key = self::getCacheKey( $title, $revid ); - ObjectCache::getMainWANInstance()->delete( $key ); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); + $key = self::getCacheKey( $cache, $title, $revid ); + $cache->delete( $key ); } } @@ -690,9 +691,10 @@ class InfoAction extends FormlessAction { protected function pageCounts( Page $page ) { $fname = __METHOD__; $config = $this->context->getConfig(); + $cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); - return ObjectCache::getMainWANInstance()->getWithSetCallback( - self::getCacheKey( $page->getTitle(), $page->getLatest() ), + return $cache->getWithSetCallback( + self::getCacheKey( $cache, $page->getTitle(), $page->getLatest() ), WANObjectCache::TTL_WEEK, function ( $oldValue, &$ttl, &$setOpts ) use ( $page, $config, $fname ) { $title = $page->getTitle(); @@ -903,11 +905,12 @@ class InfoAction extends FormlessAction { } /** + * @param WANObjectCache $cache * @param Title $title * @param int $revId * @return string */ - protected static function getCacheKey( Title $title, $revId ) { - return wfMemcKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION ); + protected static function getCacheKey( WANObjectCache $cache, Title $title, $revId ) { + return $cache->makeKey( 'infoaction', md5( $title->getPrefixedText() ), $revId, self::VERSION ); } } -- 2.20.1