From: Glaisher Date: Sat, 27 Aug 2016 16:44:51 +0000 (+0500) Subject: Add ParserFetchTemplate hook X-Git-Tag: 1.31.0-rc.0~4856^2 X-Git-Url: http://git.cyclocoop.org/%22.%28%24lien.?a=commitdiff_plain;h=8c5aa2d645b184ef1bebc05649323b61ea5e4e55;p=lhc%2Fweb%2Fwiklou.git Add ParserFetchTemplate hook This allows extensions to add custom content for transclusion text if they want. Bug: T47096 Change-Id: I0de1c96bb968a99a2c81a9977655780a78988a20 --- diff --git a/docs/hooks.txt b/docs/hooks.txt index a0ee8bde3a..5c0d15b671 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -2404,6 +2404,13 @@ $revId: ID of the revision that was parsed to create $parserOutput 'ParserCloned': Called when the parser is cloned. $parser: Newly-cloned Parser object +'ParserFetchTemplate': Called when the parser fetches a template +$parser: Parser Parser object or false +$title: Title object of the template to be fetched +$rev: Revision object of the template +&$text: Transclusion text of the template or false or null +&$deps: Array of template dependencies with 'title', 'page_id', 'rev_id' keys + 'ParserFirstCallInit': Called when the parser initialises for the first time. &$parser: Parser object being cleared diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index b116bd4451..8c7c590003 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3556,6 +3556,9 @@ class Parser { $content = $rev->getContent(); $text = $content ? $content->getWikitextForTransclusion() : null; + Hooks::run( 'ParserFetchTemplate', + [ $parser, $title, $rev, &$text, &$deps ] ); + if ( $text === false || $text === null ) { $text = false; break;