jenkins-bot has submitted this change and it was merged. Change subject: registration: Fix having multiple callbacks for a single hook ......................................................................
registration: Fix having multiple callbacks for a single hook Bug: T98975 Change-Id: I40ff36090d18344fabdb018519209671b7883fa1 --- M includes/registration/ExtensionProcessor.php M tests/phpunit/includes/registration/ExtensionProcessorTest.php 2 files changed, 24 insertions(+), 2 deletions(-) Approvals: Gergő Tisza: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 4b9a754..23a2993 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -152,8 +152,10 @@ 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 b95316c..d47ffa9 100644 --- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php @@ -36,6 +36,10 @@ } public static function provideRegisterHooks() { + // Format: + // Current $wgHooks + // Content in extension.json + // Expected value of $wgHooks return array( // No hooks array( @@ -64,6 +68,22 @@ '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' ), + ), + ), ); } -- To view, visit https://gerrit.wikimedia.org/r/210761 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I40ff36090d18344fabdb018519209671b7883fa1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits