parser: Avoid deprecated wfMemcKey()
authorKunal Mehta <legoktm@member.fsf.org>
Thu, 25 May 2017 19:05:49 +0000 (12:05 -0700)
committerKunal Mehta <legoktm@member.fsf.org>
Thu, 25 May 2017 19:05:49 +0000 (12:05 -0700)
Tested that parser cache keys stay the same, before and after this
change.

Also use the more obvious ObjectCache::getLocalClusterInstance() instead
of looking up the main cache type in config and using
ObjectCache::getInstance().

Change-Id: Icef646b3c05e732ef4079d6900e6bce111debf2b

includes/parser/ParserCache.php
includes/parser/Preprocessor.php

index f76c0b5..76a7e1e 100644 (file)
@@ -67,7 +67,7 @@ class ParserCache {
                $pageid = $article->getId();
                $renderkey = (int)( $wgRequest->getVal( 'action' ) == 'render' );
 
-               $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" );
+               $key = $this->mMemc->makeKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" );
                return $key;
        }
 
@@ -76,7 +76,7 @@ class ParserCache {
         * @return mixed|string
         */
        protected function getOptionsKey( $page ) {
-               return wfMemcKey( 'pcache', 'idoptions', $page->getId() );
+               return $this->mMemc->makeKey( 'pcache', 'idoptions', $page->getId() );
        }
 
        /**
index cb8e3a7..24474d5 100644 (file)
@@ -72,12 +72,12 @@ abstract class Preprocessor {
                        return false;
                }
 
-               $key = wfMemcKey(
+               $cache = ObjectCache::getLocalClusterInstance();
+               $key = $cache->makeKey(
                        defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : static::class,
                        md5( $text ), $flags );
                $value = sprintf( "%08d", static::CACHE_VERSION ) . $tree;
 
-               $cache = ObjectCache::getInstance( $config->get( 'MainCacheType' ) );
                $cache->set( $key, $value, 86400 );
 
                LoggerFactory::getInstance( 'Preprocessor' )
@@ -101,9 +101,9 @@ abstract class Preprocessor {
                        return false;
                }
 
-               $cache = ObjectCache::getInstance( $config->get( 'MainCacheType' ) );
+               $cache = ObjectCache::getLocalClusterInstance();
 
-               $key = wfMemcKey(
+               $key = $cache->makeKey(
                        defined( 'static::CACHE_PREFIX' ) ? static::CACHE_PREFIX : static::class,
                        md5( $text ), $flags );