r37640 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37639‎ | r37640 | r37641 >
Date:11:47, 14 July 2008
Author:catrope
Status:old
Tags:
Comment:
RandomImage: Use ParserFirstCallInit hook so $wgParser isn't unstubbed on every single request
Modified paths:
  • /trunk/extensions/RandomImage/RandomImage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RandomImage/RandomImage.php
@@ -12,7 +12,6 @@
1313 if( defined( 'MEDIAWIKI' ) ) {
1414
1515 $wgAutoloadClasses['RandomImage'] = dirname( __FILE__ ) . '/RandomImage.class.php';
16 - $wgExtensionFunctions[] = 'efRandomImage';
1716 $wgExtensionCredits['parserhook'][] = array(
1817 'name' => 'RandomImage',
1918 'author' => 'Rob Church',
@@ -23,6 +22,8 @@
2423 'descriptionmsg' => 'randomimage-desc',
2524 );
2625 $wgExtensionMessagesFiles['RandomImage'] = dirname(__FILE__) . '/RandomImage.i18n.php';
 26+ $wgHooks['ParserAfterStrip'][] = 'RandomImage::stripHook';
 27+ $wgHooks['ParserFirstCallInit'][] = 'efRandomImage';
2728
2829 /**
2930 * Set this to true to disable the parser cache for pages which
@@ -40,10 +41,9 @@
4142 /**
4243 * Extension initialisation function
4344 */
44 - function efRandomImage() {
45 - global $wgParser, $wgHooks;
46 - $wgParser->setHook( 'randomimage', 'RandomImage::renderHook' );
47 - $wgHooks['ParserAfterStrip'][] = 'RandomImage::stripHook';
 45+ function efRandomImage($parser) {
 46+ $parser->setHook( 'randomimage', 'RandomImage::renderHook' );
 47+ return true;
4848 }
4949
5050 } else {

Status & tagging log