Legoktm has uploaded a new change for review.
https://gerrit.wikimedia.org/r/231980
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
(cherry picked from commit 2fcd5d7909401e1fec9856999ba439eed4d01561)
---
M includes/registration/ExtensionProcessor.php
M tests/phpunit/includes/registration/ExtensionProcessorTest.php
2 files changed, 24 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/80/231980/1
diff --git a/includes/registration/ExtensionProcessor.php
b/includes/registration/ExtensionProcessor.php
index bb8fb32..a11f1aa 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -166,8 +166,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;
+ }
}
}
}
diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php
b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
index 8715711..9474496 100644
--- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php
+++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
@@ -38,6 +38,10 @@
}
public static function provideRegisterHooks() {
+ // Format:
+ // Current $wgHooks
+ // Content in extension.json
+ // Expected value of $wgHooks
return array(
// No hooks
array(
@@ -66,6 +70,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/231980
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I40ff36090d18344fabdb018519209671b7883fa1
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_25
Gerrit-Owner: Legoktm <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits