r55796 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55795‎ | r55796 | r55797 >
Date:01:05, 4 September 2009
Author:tstarling
Status:ok
Tags:
Comment:
Patches for bugs 20490 and 20491 by Juliano F. Ravasi (improper use of the ParserFirstCallInit hook). If we want to drop support for 1.11, that can be done in a subsequent commit.
Modified paths:
  • /trunk/extensions/ImageMap/ImageMap.php (modified) (history)
  • /trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ImageMap/ImageMap.php
@@ -6,7 +6,7 @@
77 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
88 $wgHooks['ParserFirstCallInit'][] = 'wfSetupImageMap';
99 } else {
10 - $wgExtensionFunctions[] = 'wfSetupImageMap';
 10+ $wgExtensionFunctions[] = 'wfSetupImageMap_legacy';
1111 }
1212
1313 $wgExtensionCredits['parserhook']['ImageMap'] = array(
@@ -18,8 +18,13 @@
1919 'descriptionmsg' => 'imagemap_desc',
2020 );
2121
22 -function wfSetupImageMap() {
23 - global $wgParser;
24 - $wgParser->setHook( 'imagemap', array( 'ImageMap', 'render' ) );
 22+function wfSetupImageMap( &$parser ) {
 23+ $parser->setHook( 'imagemap', array( 'ImageMap', 'render' ) );
2524 return true;
2625 }
 26+
 27+/* Provided for pre-1.12 MediaWiki compatibility. */
 28+function wfSetupImageMap_legacy() {
 29+ global $wgParser;
 30+ return wfSetupImageMap( $wgParser );
 31+}
Index: trunk/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php
@@ -59,15 +59,20 @@
6060 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
6161 $wgHooks['ParserFirstCallInit'][] = 'efSyntaxHighlight_GeSHiSetup';
6262 } else {
63 - $wgExtensionFunctions[] = 'efSyntaxHighlight_GeSHiSetup';
 63+ $wgExtensionFunctions[] = 'efSyntaxHighlight_GeSHiSetup_legacy';
6464 }
6565
6666 /**
6767 * Register parser hook
6868 */
69 -function efSyntaxHighlight_GeSHiSetup() {
70 - global $wgParser;
71 - $wgParser->setHook( 'source', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );
72 - $wgParser->setHook( 'syntaxhighlight', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );
 69+function efSyntaxHighlight_GeSHiSetup( &$parser ) {
 70+ $parser->setHook( 'source', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );
 71+ $parser->setHook( 'syntaxhighlight', array( 'SyntaxHighlight_GeSHi', 'parserHook' ) );
7372 return true;
7473 }
 74+
 75+/* Provided for pre-1.12 MediaWiki compatibility. */
 76+function efSyntaxHighlight_GeSHiSetup_legacy() {
 77+ global $wgParser;
 78+ return efSyntaxHighlight_GeSHiSetup( $wgParser );
 79+}

Status & tagging log