Cenarium has uploaded a new change for review. https://gerrit.wikimedia.org/r/277944
Change subject: Allow parser cache to expect another revision than the latest ...................................................................... Allow parser cache to expect another revision than the latest This allows extensions to specify in the parser cache another revision than the latest that should be checked against the cached revision. For example, FlaggedRevs, whose class FRParserCacheStable extends ParserCache, can compare the cached revision to the stable revision. Change-Id: I176870f882564a41fc8f2c59c993cb2ef04c3837 --- M includes/parser/CacheTime.php M includes/parser/ParserCache.php 2 files changed, 16 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/44/277944/1 diff --git a/includes/parser/CacheTime.php b/includes/parser/CacheTime.php index 2451390..dc22ce7 100644 --- a/includes/parser/CacheTime.php +++ b/includes/parser/CacheTime.php @@ -162,7 +162,7 @@ * deployed. Someday that should probably be changed. * * @since 1.23 - * @param int $id The affected article's current revision id + * @param int $id The affected article's expected revision id * @return bool */ public function isDifferentRevision( $id ) { diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index bd5afaf..2d48978 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -81,6 +81,17 @@ } /** + * @param CacheTime $optionsKey + * @param WikiPage $article + * @param int &$revId + * @return bool + */ + protected function isInvalidRevision( CacheTime $optionsKey, WikiPage $article, &$revId ) { + $revId = $article->getLatest(); + return $optionsKey->isDifferentRevision( $revId ); + } + + /** * Provides an E-Tag suitable for the whole page. Note that $article * is just the main wikitext. The E-Tag has to be unique to the whole * page, even if the article itself is the same, so it uses the @@ -149,11 +160,10 @@ wfDebug( "Parser options key expired, touched " . $article->getTouched() . ", epoch $wgCacheEpoch, cached $cacheTime\n" ); return false; - } elseif ( $optionsKey->isDifferentRevision( $article->getLatest() ) ) { + } elseif ( $this->isInvalidRevision( $optionsKey, $article, &$revId ) ) { wfIncrStats( "pcache.miss.revid" ); - $revId = $article->getLatest(); $cachedRevId = $optionsKey->getCacheRevisionId(); - wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" ); + wfDebug( "ParserOutput key is for an old revision, expected $revId, cached $cachedRevId\n" ); return false; } @@ -225,12 +235,11 @@ wfDebug( "ParserOutput key expired, touched $touched, " . "epoch $wgCacheEpoch, cached $cacheTime\n" ); $value = false; - } elseif ( $value->isDifferentRevision( $article->getLatest() ) ) { + } elseif ( $this->isInvalidRevision( $value, $article, &$revId ) ) { wfIncrStats( "pcache.miss.revid" ); - $revId = $article->getLatest(); $cachedRevId = $value->getCacheRevisionId(); wfDebug( - "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" + "ParserOutput key is for an old revision, expected $revId, cached $cachedRevId\n" ); $value = false; } elseif ( -- To view, visit https://gerrit.wikimedia.org/r/277944 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I176870f882564a41fc8f2c59c993cb2ef04c3837 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits