X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FParserCache.php;h=7043b4a9603fd52fcb6a757952d6023b3042688e;hb=84feb57e2f1656d3a0959105d9af9393a0c2ae7e;hp=0faa40a839466e105a6222d128d4f7a72263f545;hpb=2fc1752333b91126ba456e1fd02e57cb3ea27f7e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/ParserCache.php b/includes/parser/ParserCache.php index 0faa40a839..7043b4a960 100644 --- a/includes/parser/ParserCache.php +++ b/includes/parser/ParserCache.php @@ -67,7 +67,7 @@ class ParserCache { // idhash seem to mean 'page id' + 'rendering hash' (r3710) $pageid = $article->getID(); - $renderkey = (int)($wgRequest->getVal( 'action' ) == 'render'); + $renderkey = (int)( $wgRequest->getVal( 'action' ) == 'render' ); $key = wfMemcKey( 'pcache', 'idhash', "{$pageid}-{$renderkey}!{$hash}" ); return $key; @@ -128,7 +128,7 @@ class ParserCache { public function getKey( $article, $popts, $useOutdated = true ) { global $wgCacheEpoch; - if( $popts instanceof User ) { + if ( $popts instanceof User ) { wfWarn( "Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n" ); $popts = ParserOptions::newFromUser( $popts ); } @@ -220,22 +220,22 @@ class ParserCache { } /** - * @param $parserOutput ParserOutput - * @param $article Article - * @param $popts ParserOptions + * @param ParserOutput $parserOutput + * @param Article $article + * @param ParserOptions $popts + * @param string $cacheTime Time when the cache was generated */ - public function save( $parserOutput, $article, $popts ) { + public function save( $parserOutput, $article, $popts, $cacheTime = null ) { $expire = $parserOutput->getCacheExpiry(); - - if( $expire > 0 ) { - $now = wfTimestampNow(); + if ( $expire > 0 ) { + $cacheTime = $cacheTime ?: wfTimestampNow(); $optionsKey = new CacheTime; $optionsKey->mUsedOptions = $parserOutput->getUsedOptions(); $optionsKey->updateCacheExpiry( $expire ); - $optionsKey->setCacheTime( $now ); - $parserOutput->setCacheTime( $now ); + $optionsKey->setCacheTime( $cacheTime ); + $parserOutput->setCacheTime( $cacheTime ); $optionsKey->setContainsOldMagic( $parserOutput->containsOldMagic() ); @@ -245,8 +245,8 @@ class ParserCache { // Save the timestamp so that we don't have to load the revision row on view $parserOutput->setTimestamp( $article->getTimestamp() ); - $parserOutput->mText .= "\n\n"; - wfDebug( "Saved in parser cache with key $parserOutputKey and timestamp $now\n" ); + $parserOutput->mText .= "\n\n"; + wfDebug( "Saved in parser cache with key $parserOutputKey and timestamp $cacheTime\n" ); // Save the parser output $this->mMemc->set( $parserOutputKey, $parserOutput, $expire );