Manual:Hooks/RejectParserCacheValue
RejectParserCacheValue | |
---|---|
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change I660679a48c)</tvar></translate> Return false to reject an otherwise usable cached value from the Parser cache. | |
<translate> Define function:</translate> | public static function onRejectParserCacheValue( $parserOutput, $wikiPage, $parserOptions ) { ... }
|
<translate> Attach hook:</translate> | <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
"Hooks": {
"RejectParserCacheValue": "MediaWiki\\Extension\\MyExtension\\Hooks::onRejectParserCacheValue"
}
}
|
<translate> Called from:</translate> | <translate> File(s):</translate> parser/ParserCache.php <translate> Function(s):</translate> get |
<translate> Interface:</translate> | RejectParserCacheValueHook.php |
<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:RejectParserCacheValue extensions</tvar>.</translate>
Summary
This hook allows extensions to reject an otherwise-successful parser cache lookup. The intent is to allow extensions to manage the eviction of archaic HTML output from the cache.
Return true
or no return value to continue, or false
to reject an otherwise usable cached value from the Parser cache.
Use Case
See patch 587264 in gerrit for an example of the use of this hook in WMF production to mitigate an issue which caused parser cache corruption. Searching for RejectParserCache
in the mediawiki-config
repository using git log -SRejectParserCache
or equivalent will list other examples of use in WMF production. See T296425 for equivalent code to manage stored content stored in RESTBase.
Parameters
$parserOutput
:ParserOutput
object$wikiPage
:WikiPage
object$parserOptions
:ParserOptions
object