38 if ( !isset( $instance ) ) {
55 $this->mMemc = $memCached;
68 $renderkey = (int)( $wgRequest->getVal(
'action' ) ==
'render' );
70 $key =
wfMemcKey(
'pcache',
'idhash',
"{$pageid}-{$renderkey}!{$hash}" );
107 "--" .
$article->getTouched() .
'"';
143 if ( $popts instanceof
User ) {
144 wfWarn(
"Use of outdated prototype ParserCache::getKey( &\$article, &\$user )\n" );
150 $optionsKey = $this->mMemc->get(
152 if ( $optionsKey instanceof
CacheTime ) {
153 if ( !$useOutdated && $optionsKey->expired(
$article->getTouched() ) ) {
155 $cacheTime = $optionsKey->getCacheTime();
157 "Parser options key expired, touched " .
$article->getTouched()
158 .
", epoch $wgCacheEpoch, cached $cacheTime\n" );
160 } elseif ( !$useOutdated && $optionsKey->isDifferentRevision(
$article->getLatest() ) ) {
163 $cachedRevId = $optionsKey->getCacheRevisionId();
165 "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
171 $usedOptions = $optionsKey->mUsedOptions;
172 wfDebug(
"Parser cache options found.\n" );
174 if ( !$useOutdated ) {
182 $popts->optionsHash( $usedOptions,
$article->getTitle() )
199 $canCache =
$article->checkTouched();
207 $parserOutputKey = $this->
getKey(
$article, $popts, $useOutdated );
208 if ( $parserOutputKey ===
false ) {
217 wfDebug(
"ParserOutput cache miss.\n" );
222 wfDebug(
"ParserOutput cache found.\n" );
227 $value->setEditSectionTokens( $popts->getEditSection() );
229 $wikiPage = method_exists(
$article,
'getPage' )
233 if ( !$useOutdated &&
$value->expired( $touched ) ) {
235 $cacheTime =
$value->getCacheTime();
237 "ParserOutput key expired, touched $touched, "
238 .
"epoch $wgCacheEpoch, cached $cacheTime\n" );
240 } elseif ( !$useOutdated &&
$value->isDifferentRevision(
$article->getLatest() ) ) {
243 $cachedRevId =
$value->getCacheRevisionId();
245 "ParserOutput key is for an old revision, latest $revId, cached $cachedRevId\n"
249 Hooks::run(
'RejectParserCacheValue', [
$value, $wikiPage, $popts ] ) ===
false
253 "ParserOutput key valid, but rejected by RejectParserCacheValue hook handler.\n"
275 $revision =
$page->getRevision();
276 $revId = $revision ? $revision->getId() : null;
281 $optionsKey->updateCacheExpiry( $expire );
283 $optionsKey->setCacheTime( $cacheTime );
285 $optionsKey->setCacheRevisionId(
$revId );
289 $popts->optionsHash( $optionsKey->mUsedOptions,
$page->getTitle() ) );
294 $msg =
"Saved in parser cache with key $parserOutputKey" .
295 " and timestamp $cacheTime" .
296 " and revision id $revId" .
303 $this->mMemc->set( $parserOutputKey,
$parserOutput, $expire );
309 'ParserCacheSaveComplete',
312 } elseif ( $expire <= 0 ) {
313 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
if(!$wgDBerrorLogTZ) $wgRequest
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.
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...
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.
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