From: Kunal Mehta Date: Wed, 13 May 2015 19:30:21 +0000 (-0700) Subject: registration: Fix having multiple callbacks for a single hook X-Git-Tag: 1.31.0-rc.0~11415^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22config_fonctions%22%2C%20%22image_process=%24process%22%29%20.%20%22?a=commitdiff_plain;h=2fcd5d7909401e1fec9856999ba439eed4d01561;p=lhc%2Fweb%2Fwiklou.git registration: Fix having multiple callbacks for a single hook Bug: T98975 Change-Id: I40ff36090d18344fabdb018519209671b7883fa1 --- diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 4b9a7546a0..23a2993ec9 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -152,8 +152,10 @@ class ExtensionProcessor implements Processor { protected function extractHooks( array $info ) { if ( isset( $info['Hooks'] ) ) { - foreach ( $info['Hooks'] as $name => $callable ) { - $this->globals['wgHooks'][$name][] = $callable; + foreach ( $info['Hooks'] as $name => $value ) { + foreach ( (array)$value as $callback ) { + $this->globals['wgHooks'][$name][] = $callback; + } } $this->processed[] = 'Hooks'; } diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php index b95316c20b..d47ffa9461 100644 --- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php @@ -36,6 +36,10 @@ class ExtensionProcessorTest extends MediaWikiTestCase { } public static function provideRegisterHooks() { + // Format: + // Current $wgHooks + // Content in extension.json + // Expected value of $wgHooks return array( // No hooks array( @@ -64,6 +68,22 @@ class ExtensionProcessorTest extends MediaWikiTestCase { 'FooBaz' => array( 'FooBazCallback' ), ), ), + // Callbacks for FooBaz wrapped in an array + array( + array(), + array( 'Hooks' => array( 'FooBaz' => array( 'Callback1' ) ) ) + self::$default, + array( + 'FooBaz' => array( 'Callback1' ), + ), + ), + // Multiple callbacks for FooBaz hook + array( + array(), + array( 'Hooks' => array( 'FooBaz' => array( 'Callback1', 'Callback2' ) ) ) + self::$default, + array( + 'FooBaz' => array( 'Callback1', 'Callback2' ), + ), + ), ); }