InfoAction: Avoid deprecated wfMemcKey()
authorKunal Mehta <legoktm@member.fsf.org>
Wed, 24 May 2017 03:36:53 +0000 (20:36 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Wed, 24 May 2017 04:01:08 +0000 (21:01 -0700)
And the deprecated ObjectCache::getMainWANInstance() while we're at it.

Change-Id: Id7bb6a8c3e8269345e054d2c2bf202304b74c3cf

includes/actions/InfoAction.php

index df7afca..0f13b17 100644 (file)
@@ -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 );
        }
 }