67 return MediaWikiServices::getInstance()->getParserCache();
95 $renderkey = (
int)(
$wgRequest->getVal(
'action' ) ==
'render' );
97 $key = $this->mMemc->makeKey(
'pcache',
'idhash',
"{$pageid}-{$renderkey}!{$hash}" );
106 return $this->mMemc->makeKey(
'pcache',
'idoptions', $page->getId() );
133 $popts->optionsHash( ParserOptions::allCacheVaryingOptions(),
$article->getTitle() ) ) .
134 "--" .
$article->getTouched() .
'"';
157 $metricSuffix =
str_replace(
'.',
'_', $metricSuffix );
158 wfIncrStats(
'pcache.' . $contentModel .
'.' . $metricSuffix );
182 if (
is_bool( $useOutdated ) ) {
183 $useOutdated = $useOutdated ? self::USE_ANYTHING : self::USE_CURRENT_ONLY;
186 if ( $popts instanceof
User ) {
187 wfWarn(
"Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n" );
188 $popts = ParserOptions::newFromUser( $popts );
192 $optionsKey = $this->mMemc->get(
194 if ( $optionsKey instanceof
CacheTime ) {
195 if ( $useOutdated < self::USE_EXPIRED && $optionsKey->expired(
$article->getTouched() ) ) {
197 $cacheTime = $optionsKey->getCacheTime();
199 "Parser options key expired, touched " .
$article->getTouched()
200 .
", epoch {$this->cacheEpoch}, cached $cacheTime\n" );
202 }
elseif ( $useOutdated < self::USE_OUTDATED &&
203 $optionsKey->isDifferentRevision(
$article->getLatest() )
207 $cachedRevId = $optionsKey->getCacheRevisionId();
209 "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
215 $usedOptions = $optionsKey->mUsedOptions;
216 wfDebug(
"Parser cache options found.\n" );
218 if ( $useOutdated < self::USE_ANYTHING ) {
221 $usedOptions = ParserOptions::allCacheVaryingOptions();
226 $popts->optionsHash( $usedOptions,
$article->getTitle() )
241 $canCache =
$article->checkTouched();
250 $useOutdated ? self::USE_OUTDATED : self::USE_CURRENT_ONLY
252 if ( $parserOutputKey ===
false ) {
259 $value = $this->mMemc->get( $parserOutputKey, BagOStuff::READ_VERIFIED );
261 wfDebug(
"ParserOutput cache miss.\n" );
266 wfDebug(
"ParserOutput cache found.\n" );
272 if ( !$useOutdated &&
$value->expired( $touched ) ) {
274 $cacheTime =
$value->getCacheTime();
276 "ParserOutput key expired, touched $touched, "
277 .
"epoch {$this->cacheEpoch}, cached $cacheTime\n" );
282 $cachedRevId =
$value->getCacheRevisionId();
284 "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
288 Hooks::run(
'RejectParserCacheValue', [
$value, $wikiPage, $popts ] ) ===
false
292 "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
316 if ( !$parserOutput->
hasText() ) {
317 throw new InvalidArgumentException(
'Attempt to cache a ParserOutput with no text set!' );
324 $revision = $page->getRevision();
325 $revId = $revision ? $revision->getId() :
null;
330 $optionsKey->updateCacheExpiry( $expire );
332 $optionsKey->setCacheTime( $cacheTime );
334 $optionsKey->setCacheRevisionId( $revId );
338 $popts->optionsHash( $optionsKey->mUsedOptions, $page->getTitle() ) );
343 $msg =
"Saved in parser cache with key $parserOutputKey" .
344 " and timestamp $cacheTime" .
345 " and revision id $revId" .
348 $parserOutput->mText .=
"\n<!-- $msg -->\n";
352 $this->mMemc->set( $parserOutputKey, $parserOutput, $expire );
355 $this->mMemc->set( $this->
getOptionsKey( $page ), $optionsKey, $expire );
358 'ParserCacheSaveComplete',
359 [ $this, $parserOutput, $page->getTitle(), $popts, $revId ]
361 }
elseif ( $expire <= 0 ) {
362 wfDebug(
"Parser output was marked as uncacheable and has not been saved.\n" );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfWarn( $msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfIncrStats( $key, $count=1)
Increment a statistics counter.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
if(! $wgDBerrorLogTZ) $wgRequest
Class representing a cache/ephemeral data store.
Parser cache specific expiry check.
setCacheTime( $t)
setCacheTime() sets the timestamp expressing when the page has been rendered.
getCacheExpiry()
Returns the number of seconds after which this object should expire.
A BagOStuff object with no objects in it.
save(ParserOutput $parserOutput, $page, $popts, $cacheTime=null, $revId=null)
getDirty( $article, $popts)
Retrieve the ParserOutput from ParserCache, even if it's outdated.
getParserOutputKey( $article, $hash)
const USE_EXPIRED
Use expired data if current data is unavailable.
__construct(BagOStuff $cache, $cacheEpoch='20030516000000')
Setup a cache pathway with a given back-end storage mechanism.
static singleton()
Get an instance of this object.
getCacheStorage()
Get the backend BagOStuff instance that powers the parser cache.
const USE_ANYTHING
Use expired data and data from different revisions, and if all else fails vary on all variable option...
string $cacheEpoch
Anything cached prior to this is invalidated.
const USE_CURRENT_ONLY
Constants for self::getKey()
getKey( $article, $popts, $useOutdated=self::USE_ANYTHING)
Generates a key for caching the given article considering the given parser options.
incrementStats( $article, $metricSuffix)
const USE_OUTDATED
Use expired data or data from different revisions if current data is unavailable.
getETag( $article, $popts)
Provides an E-Tag suitable for the whole page.
hasText()
Returns true if text was passed to the constructor, or set using setText().
getUsedOptions()
Returns the options from its ParserOptions which have been taken into account to produce this output.
setTimestamp( $timestamp)
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file & $article
processing should stop and the error should be shown to the user * false