wiki.techinc.nl/includes/parser/Hook
C. Scott Ananian 0676256ccc parser: new BeforeParserFetchTemplateRevisionRecord hook
This new hook provides for the use case in T47096 (allowing the
Translate extension to transclude a page from another language) by
adding a new hook which would let us deprecate and replace two awkward
legacy hooks (one with an embarrassing capitalization issue).  The new
hook is a little more tightly scoped in terms of what it allows and
gives access to, and it uses the new RevisionRecord API.

In addition, the new hook uses LinkTarget instead of Title per
current best practices. (PageIdentity is not appropriate for
reasons documented at the hook invocation site.)

The original BeforeParserFetchTemplateAndtitle (sic) hook allowed
redirecting the revision id of a template inclusion, but not the
title. The only known current use is Extension:ApprovedRevs; the
FlaggedRevs extension replaces the entire function using
ParserOptions::setCurrentRevisionRecordCallback().

Extension:Translate would like to redirect the title as well, possibly
recursively (for a limited number of hops) to handle fallback
languages.  That is, when invoked on Foo/fr, including Template:Bar
would redirect to Template:Bar/fr -- and, if that doesn't exist, then
Template:Bar/fr would redirect to its fallback language, say
Template:Bar/en. It uses the top-level page title as context to set
the desired page language.  This would require 2 invocations of the
hook; we've set the recursion limit to 3 to provide a little bit
of future-proofing.

The hook added in this patch uses RevisionRecord instead of int
$rev_id, and thus can handle the case where the redirect is to a page
which doesn't exist (by setting the RevisionRecord to a
MutableRevisionRecord with the correct title and no main slot content)
in the fallback language case above.

The new hook deprecates BeforeParserFetchTemplateAndtitle and replaces
ParserFetchTemplate as well (deprecated in 1.35).  Code search:

https://codesearch.wmcloud.org/search/?q=BeforeParserFetchTemplateAndtitle&i=nope&files=&repos=

Bug: T47096
Change-Id: Ia5b5d339706ce4084c16948300e0e3418b11792e
2021-02-05 09:37:32 -05:00
..
AfterParserFetchFileAndTitleHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
BeforeParserFetchFileAndTitleHook.php Merge "Document hook names in hook interfaces." 2020-10-02 16:15:21 +00:00
BeforeParserFetchTemplateAndtitleHook.php parser: new BeforeParserFetchTemplateRevisionRecord hook 2021-02-05 09:37:32 -05:00
BeforeParserFetchTemplateRevisionRecordHook.php parser: new BeforeParserFetchTemplateRevisionRecord hook 2021-02-05 09:37:32 -05:00
BeforeParserrenderImageGalleryHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
GetLinkColoursHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
InternalParseBeforeLinksHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
InternalParseBeforeSanitizeHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
IsValidEmailAddrHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
PageRenderingHashHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserAfterParseHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserAfterTidyHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserBeforeInternalParseHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserBeforePreprocessHook.php Remove documentation that literally repeats the code 2020-10-27 19:20:26 +00:00
ParserCacheSaveCompleteHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserClearStateHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserClonedHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserFetchTemplateHook.php parser: new BeforeParserFetchTemplateRevisionRecord hook 2021-02-05 09:37:32 -05:00
ParserFirstCallInitHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserGetVariableValueSwitchHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserGetVariableValueTsHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserGetVariableValueVarCacheHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserLimitReportFormatHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserLimitReportPrepareHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserMakeImageParamsHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserOptionsRegisterHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserOutputPostCacheTransformHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserPreSaveTransformCompleteHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
ParserSectionCreateHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00
RejectParserCacheValueHook.php Document hook names in hook interfaces. 2020-09-27 12:03:12 +02:00