/** * Retrieve the ParserOutput from ParserCache. * false if not found or outdated. * * @param WikiPage|Article $article * @param ParserOptions $popts * @param bool $useOutdated (default false) * * @return ParserOutput|bool False on failure */ public function get($article, $popts, $useOutdated = false) { global $wgCacheEpoch; $canCache = $article->checkTouched(); if (!$canCache) { // It's a redirect now return false; } $touched = $article->getTouched(); $parserOutputKey = $this->getKey($article, $popts, $useOutdated); if ($parserOutputKey === false) { wfIncrStats('pcache.miss.absent'); return false; } $value = $this->mMemc->get($parserOutputKey); if (!$value) { wfDebug("ParserOutput cache miss.\n"); wfIncrStats("pcache.miss.absent"); return false; } wfDebug("ParserOutput cache found.\n"); // The edit section preference may not be the appropiate one in // the ParserOutput, as we are not storing it in the 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(); wfDebug("ParserOutput key expired, touched {$touched}, " . "epoch {$wgCacheEpoch}, cached {$cacheTime}\n"); $value = false; } elseif ($value->isDifferentRevision($article->getLatest())) { wfIncrStats("pcache.miss.revid"); $revId = $article->getLatest(); $cachedRevId = $value->getCacheRevisionId(); wfDebug("ParserOutput key is for an old revision, latest {$revId}, cached {$cachedRevId}\n"); $value = 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; } else { wfIncrStats("pcache.hit"); } return $value; }
/** * Retrieve the ParserOutput from ParserCache. * false if not found or outdated. * * @param Article $article * @param ParserOptions $popts * @param bool $useOutdated (default false) * * @return ParserOutput|bool False on failure */ public function get($article, $popts, $useOutdated = false) { global $wgCacheEpoch; wfProfileIn(__METHOD__); $canCache = $article->checkTouched(); if (!$canCache) { // It's a redirect now wfProfileOut(__METHOD__); return false; } $touched = $article->getTouched(); $parserOutputKey = $this->getKey($article, $popts, $useOutdated); if ($parserOutputKey === false) { wfIncrStats('pcache_miss_absent'); wfProfileOut(__METHOD__); return false; } $value = $this->mMemc->get($parserOutputKey); if (!$value) { wfDebug("ParserOutput cache miss.\n"); wfIncrStats("pcache_miss_absent"); wfProfileOut(__METHOD__); return false; } wfDebug("ParserOutput cache found.\n"); // The edit section preference may not be the appropiate one in // the ParserOutput, as we are not storing it in the parsercache // key. Force it here. See bug 31445. $value->setEditSectionTokens($popts->getEditSection()); if (!$useOutdated && $value->expired($touched)) { wfIncrStats("pcache_miss_expired"); $cacheTime = $value->getCacheTime(); wfDebug("ParserOutput key expired, touched {$touched}, " . "epoch {$wgCacheEpoch}, cached {$cacheTime}\n"); $value = false; } elseif ($value->isDifferentRevision($article->getLatest())) { wfIncrStats("pcache_miss_revid"); $revId = $article->getLatest(); $cachedRevId = $value->getCacheRevisionId(); wfDebug("ParserOutput key is for an old revision, latest {$revId}, cached {$cachedRevId}\n"); $value = false; } else { wfIncrStats("pcache_hit"); } wfProfileOut(__METHOD__); return $value; }