jenkins-bot has submitted this change and it was merged.

Change subject: resourceloader: Deduplicate module registration conflicts
......................................................................


resourceloader: Deduplicate module registration conflicts

If an attempt is made to register a ResourceLoader module which has already
been registered, instead of bailing with an error, issue a warning instead, and
allow the lattermost set of module parameters to stick.

Because modules are registered from extensions, and because modules are often
migrated from one extension to another as extensions are refactored, and
because the developers of different extensions are not always aware of each
other's work, throwing an error runs a high risk of causing an outage.

Bug: T116628
Change-Id: Ie3499d9f2ff3bf071f1c2b0176e19440ff55211c
---
M includes/resourceloader/ResourceLoader.php
1 file changed, 7 insertions(+), 5 deletions(-)

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

Objections:
  Legoktm: There's a problem with this change, please improve



diff --git a/includes/resourceloader/ResourceLoader.php 
b/includes/resourceloader/ResourceLoader.php
index c9c60bc..dfd9a8ff 100644
--- a/includes/resourceloader/ResourceLoader.php
+++ b/includes/resourceloader/ResourceLoader.php
@@ -322,13 +322,15 @@
                // Allow multiple modules to be registered in one call
                $registrations = is_array( $name ) ? $name : array( $name => 
$info );
                foreach ( $registrations as $name => $info ) {
-                       // Disallow duplicate registrations
+                       // Warn on duplicate registrations
                        if ( isset( $this->moduleInfos[$name] ) ) {
                                // A module has already been registered by this 
name
-                               throw new MWException(
-                                       'ResourceLoader duplicate registration 
error. ' .
-                                       'Another module has already been 
registered as ' . $name
-                               );
+                               if ( $this->moduleInfos[$name] === $info ) {
+                                       $this->logger->warning(
+                                               'ResourceLoader duplicate 
registration warning. ' .
+                                               'Another module has already 
been registered as ' . $name
+                                       );
+                               }
                        }
 
                        // Check $name for validity

-- 
To view, visit https://gerrit.wikimedia.org/r/248932
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie3499d9f2ff3bf071f1c2b0176e19440ff55211c
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Ori.livneh <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to