From e4c41d5126d074633b2f3de027f4ca4e7b915f77 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 23 Jun 2015 14:57:52 -0700 Subject: [PATCH 1/1] Document that ParserCache::get() may be passed a WikiPage or Article This is terrible, but at least it is no longer lying. Change-Id: Id1cc1616b60dbde45a12ce9a23b76282efd1c6a9 --- includes/parser/ParserCache.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 2919c6c449..117b6e7544 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -176,7 +176,7 @@ class ParserCache { * Retrieve the ParserOutput from ParserCache. * false if not found or outdated. * - * @param WikiPage $article + * @param WikiPage|Article $article * @param ParserOptions $popts * @param bool $useOutdated (default false) * @@ -213,6 +213,11 @@ class ParserCache { // key. Force it here. See bug 31445. $value->setEditSectionTokens( $popts->getEditSection() ); + $wikiPage = method_exists( $article, 'getPage' ) + ? $article->getPage() + : $article; + + if ( !$useOutdated && $value->expired( $touched ) ) { wfIncrStats( "pcache.miss.expired" ); $cacheTime = $value->getCacheTime(); @@ -225,7 +230,7 @@ class ParserCache { $cachedRevId = $value->getCacheRevisionId(); wfDebug( "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n" ); $value = false; - } elseif ( Hooks::run( 'RejectParserCacheValue', array( $value, $article, $popts ) ) === false ) { + } elseif ( Hooks::run( 'RejectParserCacheValue', array( $value, $wikiPage, $popts ) ) === false ) { wfIncrStats( 'pcache.miss.rejected' ); wfDebug( "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n" ); $value = false; -- 2.20.1