Available from version 1.36.0 (Gerrit change 617294)
This hook is called before a template is fetched by Parser.
Define function:
public static function onBeforeParserFetchTemplateRevisionRecord( ?LinkTarget $contextTitle, LinkTarget $title, bool &$skip, ?RevisionRecord &$revRecord ) { ... }
Attach hook: In extension.json:
	"Hooks": {
		"BeforeParserFetchTemplateRevisionRecord": "MyExtensionHooks::onBeforeParserFetchTemplateRevisionRecord"
Called from: File(s): parser/Parser.php
Function(s): statelessFetchTemplate
Interface: BeforeParserFetchTemplateRevisionRecordHook.php

For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:BeforeParserFetchTemplateRevisionRecord extensions.

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).


  • $contextTitle: The top-level page title as a MediaWiki\Linker\LinkTarget, if any
  • $title: A MediaWiki\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), or null