r84197 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84196‎ | r84197 | r84198 >
Date:19:30, 17 March 2011
Author:ialex
Status:deferred
Tags:
Comment:
Use ParserFirstCallInit hook to register parser functions instead of an extension function
Modified paths:
  • /trunk/extensions/ArrayExtension/ArrayExtension.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArrayExtension/ArrayExtension.php
@@ -42,7 +42,7 @@
4343 die( 'This file is a MediaWiki extension, it is not a valid entry point' );
4444 }
4545
46 -$wgExtensionFunctions[] = 'efSetupArrayExtension';
 46+$wgHooks['ParserFirstCallInit'][] = 'efArrayExtensionParserFirstCallInit';
4747
4848 $wgExtensionCredits['parserhook'][] = array(
4949 'path' => __FILE__,
@@ -748,33 +748,35 @@
749749 }
750750 }
751751
752 -function efSetupArrayExtension() {
753 - global $wgParser, $wgArrayExtension;
 752+function efArrayExtensionParserFirstCallInit( $parser ) {
 753+ global $wgArrayExtension;
754754
755755 $wgArrayExtension = new ArrayExtension;
756 - $wgParser->setFunctionHook( 'arraydefine', array( &$wgArrayExtension, 'arraydefine' ) );
 756+ $parser->setFunctionHook( 'arraydefine', array( &$wgArrayExtension, 'arraydefine' ) );
757757
758 - if ( defined( get_class( $wgParser ) . '::SFH_OBJECT_ARGS' ) ) {
759 - $wgParser->setFunctionHook( 'arrayprint', array( &$wgArrayExtension, 'arrayprintObj' ), SFH_OBJECT_ARGS );
 758+ if ( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
 759+ $parser->setFunctionHook( 'arrayprint', array( &$wgArrayExtension, 'arrayprintObj' ), SFH_OBJECT_ARGS );
760760 } else {
761 - $wgParser->setFunctionHook( 'arrayprint', array( &$wgArrayExtension, 'arrayprint' ) );
 761+ $parser->setFunctionHook( 'arrayprint', array( &$wgArrayExtension, 'arrayprint' ) );
762762 }
763763
764 - $wgParser->setFunctionHook( 'arraysize', array( &$wgArrayExtension, 'arraysize' ) );
765 - $wgParser->setFunctionHook( 'arrayindex', array( &$wgArrayExtension, 'arrayindex' ) );
766 - $wgParser->setFunctionHook( 'arraysearch', array( &$wgArrayExtension, 'arraysearch' ) );
 764+ $parser->setFunctionHook( 'arraysize', array( &$wgArrayExtension, 'arraysize' ) );
 765+ $parser->setFunctionHook( 'arrayindex', array( &$wgArrayExtension, 'arrayindex' ) );
 766+ $parser->setFunctionHook( 'arraysearch', array( &$wgArrayExtension, 'arraysearch' ) );
767767
768 - $wgParser->setFunctionHook( 'arraysort', array( &$wgArrayExtension, 'arraysort' ) );
769 - $wgParser->setFunctionHook( 'arrayunique', array( &$wgArrayExtension, 'arrayunique' ) );
770 - $wgParser->setFunctionHook( 'arrayreset', array( &$wgArrayExtension, 'arrayreset' ) );
 768+ $parser->setFunctionHook( 'arraysort', array( &$wgArrayExtension, 'arraysort' ) );
 769+ $parser->setFunctionHook( 'arrayunique', array( &$wgArrayExtension, 'arrayunique' ) );
 770+ $parser->setFunctionHook( 'arrayreset', array( &$wgArrayExtension, 'arrayreset' ) );
771771
772 - $wgParser->setFunctionHook( 'arraymerge', array( &$wgArrayExtension, 'arraymerge' ) );
773 - $wgParser->setFunctionHook( 'arrayslice', array( &$wgArrayExtension, 'arrayslice' ) );
 772+ $parser->setFunctionHook( 'arraymerge', array( &$wgArrayExtension, 'arraymerge' ) );
 773+ $parser->setFunctionHook( 'arrayslice', array( &$wgArrayExtension, 'arrayslice' ) );
774774
775 - $wgParser->setFunctionHook( 'arrayunion', array( &$wgArrayExtension, 'arrayunion' ) );
776 - $wgParser->setFunctionHook( 'arrayintersect', array( &$wgArrayExtension, 'arrayintersect' ) );
777 - $wgParser->setFunctionHook( 'arraydiff', array( &$wgArrayExtension, 'arraydiff' ) );
778 - $wgParser->setFunctionHook( 'arraysearcharray', array( &$wgArrayExtension, 'arraysearcharray' ) );
 775+ $parser->setFunctionHook( 'arrayunion', array( &$wgArrayExtension, 'arrayunion' ) );
 776+ $parser->setFunctionHook( 'arrayintersect', array( &$wgArrayExtension, 'arrayintersect' ) );
 777+ $parser->setFunctionHook( 'arraydiff', array( &$wgArrayExtension, 'arraydiff' ) );
 778+ $parser->setFunctionHook( 'arraysearcharray', array( &$wgArrayExtension, 'arraysearcharray' ) );
 779+
 780+ return true;
779781 }
780782
781783 function efArrayExtensionLanguageGetMagic( &$magicWords, $langCode ) {

Status & tagging log