Merge "In ParserCache, respect $useOutdated"
[lhc/web/wiklou.git] / includes / parser / ParserCache.php
index c03b5c2..21486ff 100644 (file)
@@ -64,7 +64,7 @@ class ParserCache {
                global $wgRequest;
 
                // idhash seem to mean 'page id' + 'rendering hash' (r3710)
-               $pageid = $article->getID();
+               $pageid = $article->getId();
                $renderkey = (int)( $wgRequest->getVal( 'action' ) == 'render' );
 
                $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" );
@@ -76,7 +76,7 @@ class ParserCache {
         * @return mixed|string
         */
        protected function getOptionsKey( $article ) {
-               $pageid = $article->getID();
+               $pageid = $article->getId();
                return wfMemcKey( 'pcache', 'idoptions', "{$pageid}" );
        }
 
@@ -139,19 +139,24 @@ class ParserCache {
                }
 
                // Determine the options which affect this article
-               $optionsKey = $this->mMemc->get( $this->getOptionsKey( $article ) );
+               $casToken = null;
+               $optionsKey = $this->mMemc->get(
+                       $this->getOptionsKey( $article ), $casToken, BagOStuff::READ_VERIFIED );
                if ( $optionsKey instanceof CacheTime ) {
                        if ( !$useOutdated && $optionsKey->expired( $article->getTouched() ) ) {
                                wfIncrStats( "pcache.miss.expired" );
                                $cacheTime = $optionsKey->getCacheTime();
-                               wfDebug( "Parser options key expired, touched " . $article->getTouched()
+                               wfDebugLog( "ParserCache",
+                                       "Parser options key expired, touched " . $article->getTouched()
                                        . ", epoch $wgCacheEpoch, cached $cacheTime\n" );
                                return false;
-                       } elseif ( $optionsKey->isDifferentRevision( $article->getLatest() ) ) {
+                       } elseif ( !$useOutdated && $optionsKey->isDifferentRevision( $article->getLatest() ) ) {
                                wfIncrStats( "pcache.miss.revid" );
                                $revId = $article->getLatest();
                                $cachedRevId = $optionsKey->getCacheRevisionId();
-                               wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" );
+                               wfDebugLog( "ParserCache",
+                                       "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
+                               );
                                return false;
                        }
 
@@ -198,7 +203,9 @@ class ParserCache {
                        return false;
                }
 
-               $value = $this->mMemc->get( $parserOutputKey );
+               $casToken = null;
+               /** @var ParserOutput $value */
+               $value = $this->mMemc->get( $parserOutputKey, $casToken, BagOStuff::READ_VERIFIED );
                if ( !$value ) {
                        wfDebug( "ParserOutput cache miss.\n" );
                        wfIncrStats( "pcache.miss.absent" );
@@ -219,22 +226,23 @@ class ParserCache {
                if ( !$useOutdated && $value->expired( $touched ) ) {
                        wfIncrStats( "pcache.miss.expired" );
                        $cacheTime = $value->getCacheTime();
-                       wfDebug( "ParserOutput key expired, touched $touched, "
+                       wfDebugLog( "ParserCache",
+                               "ParserOutput key expired, touched $touched, "
                                . "epoch $wgCacheEpoch, cached $cacheTime\n" );
                        $value = false;
-               } elseif ( $value->isDifferentRevision( $article->getLatest() ) ) {
+               } elseif ( !$useOutdated && $value->isDifferentRevision( $article->getLatest() ) ) {
                        wfIncrStats( "pcache.miss.revid" );
                        $revId = $article->getLatest();
                        $cachedRevId = $value->getCacheRevisionId();
-                       wfDebug(
+                       wfDebugLog( "ParserCache",
                                "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
                        );
                        $value = false;
                } elseif (
-                       Hooks::run( 'RejectParserCacheValue', array( $value, $wikiPage, $popts ) ) === false
+                       Hooks::run( 'RejectParserCacheValue', [ $value, $wikiPage, $popts ] ) === false
                ) {
                        wfIncrStats( 'pcache.miss.rejected' );
-                       wfDebug(
+                       wfDebugLog( "ParserCache",
                                "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
                        );
                        $value = false;
@@ -292,7 +300,7 @@ class ParserCache {
 
                        Hooks::run(
                                'ParserCacheSaveComplete',
-                               array( $this, $parserOutput, $page->getTitle(), $popts, $revId )
+                               [ $this, $parserOutput, $page->getTitle(), $popts, $revId ]
                        );
                } else {
                        wfDebug( "Parser output was marked as uncacheable and has not been saved.\n" );