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
Bug: T109243
Change-Id: I40ff36090d18344fabdb018519209671b7883fa1
(cherry picked from commit 2fcd5d7909401e1fec9856999ba439eed4d01561)
---
M RELEASE-NOTES-1.25
M includes/registration/ExtensionProcessor.php
M tests/phpunit/includes/registration/ExtensionProcessorTest.php
3 files changed, 32 insertions(+), 2 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/RELEASE-NOTES-1.25 b/RELEASE-NOTES-1.25
index 6d32a44..e53dfbe 100644
--- a/RELEASE-NOTES-1.25
+++ b/RELEASE-NOTES-1.25
@@ -1,6 +1,14 @@
 Security reminder: If you have PHP's register_globals option set, you must
 turn it off. MediaWiki will not work with it enabled.
 
+== MediaWiki 1.25.3 ==
+
+THIS IS NOT YET A RELEASE!
+
+=== Changes since 1.25.2 ===
+
+* (T98975) Fix having multiple callbacks for a single hook.
+
 == MediaWiki 1.25.2 ==
 
 This is a security and maintenance release of the MediaWiki 1.25 branch.
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: merged
Gerrit-Change-Id: I40ff36090d18344fabdb018519209671b7883fa1
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_25
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to