r55755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55754‎ | r55755 | r55756 >
Date:13:16, 2 September 2009
Author:ialex
Status:resolved (Comments)
Tags:
Comment:
Use ParserFirstCallInit hook if available
Modified paths:
  • /trunk/extensions/WikiArticleFeeds/WikiArticleFeeds.php (modified) (history)

Diff [purge]

Index: trunk/extensions/WikiArticleFeeds/WikiArticleFeeds.php
@@ -184,7 +184,10 @@
185185 }
186186
187187 # Add Extension Functions
188 -$wgExtensionFunctions[] = 'wfWikiArticleFeedsParserSetup';
 188+if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) )
 189+ $wgHooks['ParserFirstCallInit'][] = 'wfWikiArticleFeedsParserSetup';
 190+else
 191+ $wgExtensionFunctions[] = 'wfWikiArticleFeedsParserSetup';
189192
190193 # Sets up the WikiArticleFeeds Parser hooks
191194 function wfWikiArticleFeedsParserSetup() {
@@ -196,6 +199,7 @@
197200 $wgParser->setHook( 'itemTags', array( $wgWikiArticleFeedsParser, 'itemTagsTag' ) );
198201
199202 $wgParser->setFunctionHook( 'itemtags', array( $wgWikiArticleFeedsParser, 'itemTagsFunction' ) );
 203+ return true;
200204 }
201205
202206 # Attach Hooks

Comments

#Comment by 😂 (talk | contribs)   13:25, 2 September 2009

I don't understand why we do this...

A) ParserFirstCallInit has been around since 1.12.0. We don't support 1.12.0 anymore, much less anything older than that. Doing this is a needless check in quite a number of extensions B) If we're using $wgParser in ParserFirstCallInit, we're defeating the purpose of the hook. &$parser might not be $wgParser, but we're assuming it is.

IMHO, we should move to just using ParserFirstCallInit and leaving out the back-compat stuff.

#Comment by IAlex (talk | contribs)   18:36, 2 September 2009
  • A) There's a comment some lines above saying "FIXME: update after 1.16 branching for new style magic words. This extension has not been branched yet." with some compat for < 1.7, so my point was to follow it :)
  • B) A lot of extensions already use this kind of calling covention (ImageMap, Poem for some examples)

Status & tagging log