38 if ( !isset( $instance ) ) {
55 $this->mMemc = $memCached;
68 $renderkey = (int)( $wgRequest->getVal(
'action' ) ==
'render' );
70 $key =
wfMemcKey(
'pcache',
'idhash',
"{$pageid}-{$renderkey}!{$hash}" );
80 return wfMemcKey(
'pcache',
'idoptions',
"{$pageid}" );
100 "--" .
$article->getTouched() .
'"';
136 if ( $popts instanceof
User ) {
137 wfWarn(
"Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n" );
143 $optionsKey = $this->mMemc->get(
145 if ( $optionsKey instanceof
CacheTime ) {
146 if ( !$useOutdated && $optionsKey->expired(
$article->getTouched() ) ) {
148 $cacheTime = $optionsKey->getCacheTime();
150 "Parser options key expired, touched " .
$article->getTouched()
151 .
", epoch $wgCacheEpoch, cached $cacheTime\n" );
153 } elseif ( !$useOutdated && $optionsKey->isDifferentRevision(
$article->getLatest() ) ) {
156 $cachedRevId = $optionsKey->getCacheRevisionId();
158 "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
164 $usedOptions = $optionsKey->mUsedOptions;
165 wfDebug(
"Parser cache options found.\n" );
167 if ( !$useOutdated ) {
175 $popts->optionsHash( $usedOptions,
$article->getTitle() )
192 $canCache =
$article->checkTouched();
200 $parserOutputKey = $this->
getKey(
$article, $popts, $useOutdated );
201 if ( $parserOutputKey ===
false ) {
210 wfDebug(
"ParserOutput cache miss.\n" );
215 wfDebug(
"ParserOutput cache found.\n" );
220 $value->setEditSectionTokens( $popts->getEditSection() );
222 $wikiPage = method_exists(
$article,
'getPage' )
226 if ( !$useOutdated &&
$value->expired( $touched ) ) {
228 $cacheTime =
$value->getCacheTime();
230 "ParserOutput key expired, touched $touched, "
231 .
"epoch $wgCacheEpoch, cached $cacheTime\n" );
233 } elseif ( !$useOutdated &&
$value->isDifferentRevision(
$article->getLatest() ) ) {
236 $cachedRevId =
$value->getCacheRevisionId();
238 "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
242 Hooks::run(
'RejectParserCacheValue', [
$value, $wikiPage, $popts ] ) ===
false
246 "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
268 $revision =
$page->getRevision();
269 $revId = $revision ? $revision->getId() : null;
274 $optionsKey->updateCacheExpiry( $expire );
276 $optionsKey->setCacheTime( $cacheTime );
278 $optionsKey->setCacheRevisionId(
$revId );
282 $popts->optionsHash( $optionsKey->mUsedOptions,
$page->getTitle() ) );
287 $msg =
"Saved in parser cache with key $parserOutputKey" .
288 " and timestamp $cacheTime" .
289 " and revision id $revId" .
296 $this->mMemc->set( $parserOutputKey,
$parserOutput, $expire );
302 'ParserCacheSaveComplete',
305 } elseif ( $expire <= 0 ) {
306 wfDebug(
"Parser output was marked as uncacheable and has not been saved.\n" );
static legacyOptions()
Returns the full array of options that would have been used by in 1.16.
processing should stop and the error should be shown to the user * false
save($parserOutput, $page, $popts, $cacheTime=null, $revId=null)
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context $revId
Parser cache specific expiry check.
getParserOutputKey($article, $hash)
when a variable name is used in a it is silently declared as a new local masking the global
static newFromUser($user)
Get a ParserOptions object from a given user.
wfDebug($text, $dest= 'all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
The User object encapsulates all of the user-specific settings (user_id, name, rights, email address, options, last login time).
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
wfDebugLog($logGroup, $text, $dest= 'all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not...
interface is intended to be more or less compatible with the PHP memcached client.
getETag($article, $popts)
Provides an E-Tag suitable for the whole page.
getDirty($article, $popts)
Retrieve the ParserOutput from ParserCache, even if it's outdated.
wfWarn($msg, $callerOffset=1, $level=E_USER_NOTICE)
Send a warning either to the debug log or in a PHP error depending on $wgDevelopmentWarnings.
getKey($article, $popts, $useOutdated=true)
Generates a key for caching the given article considering the given parser options.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context $parserOutput
controlled by $wgMainCacheType * $parserMemc
wfTimestampNow()
Convenience function; returns MediaWiki timestamp for the present time.
wfIncrStats($key, $count=1)
Increment a statistics counter.
A BagOStuff object with no objects in it.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
__construct(BagOStuff $memCached)
Setup a cache pathway with a given back-end storage mechanism.
static singleton()
Get an instance of this object.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
wfMemcKey()
Make a cache key for the local wiki.
$wgCacheEpoch
Set this to current time to invalidate all prior cached pages.
if(is_null($wgLocalTZoffset)) if(!$wgDBerrorLogTZ) $wgRequest
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page