Manual:Hooks/BeforeParserFetchTemplateRevisionRecord
BeforeParserFetchTemplateRevisionRecord | |
---|---|
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change 617294)</tvar></translate> This hook is called before a template is fetched by Parser. | |
<translate> Define function:</translate> | public static function onBeforeParserFetchTemplateRevisionRecord( ?LinkTarget $contextTitle, LinkTarget $title, bool &$skip, ?RevisionRecord &$revRecord ) { ... }
|
<translate> Attach hook:</translate> | <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
"Hooks": {
"BeforeParserFetchTemplateRevisionRecord": "MediaWiki\\Extension\\MyExtension\\Hooks::onBeforeParserFetchTemplateRevisionRecord"
}
}
|
<translate> Called from:</translate> | <translate> File(s):</translate> parser/Parser.php <translate> Function(s):</translate> statelessFetchTemplate |
<translate> Interface:</translate> | BeforeParserFetchTemplateRevisionRecordHook.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:BeforeParserFetchTemplateRevisionRecord extensions</tvar>.</translate>
It allows redirection of the title and/or revision ID of the template. For example: the template could be redirected to an appropriately localized version of the template; or the template fetch could be redirected to a 'stable revision' of the template. If the returned MediaWiki\Revision\RevisionRecord
does not exist, its title will be added to the page dependencies and then this hook will be invoked again to resolve that title. This allows for fallback chains (of limited length).
Parameters
$contextTitle
: The top-level page title as aMediaWiki\Linker\LinkTarget
, if any$title
: AMediaWiki\Linker\LinkTarget
instance, representing the template link (from the literal wikitext)&$skip
: Skip this template and link it? (bool
)&$revRecord
: The desired revision record (MediaWiki\Revision\RevisionRecord
), ornull
Notes
- This hook replaces BeforeParserFetchTemplateAndtitle, which was deprecated in MediaWiki 1.36.