resourceloader: Run ResourceLoaderRegisterModules after wgResourceModules
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 16 Jun 2015 21:14:10 +0000 (22:14 +0100)
committerKrinkle <krinklemail@gmail.com>
Fri, 18 Sep 2015 19:06:03 +0000 (19:06 +0000)
We don't allow modifying existing modules or registering the same module twice.

We do have an established convention of registering plugins for optional
dependencies conditionally.

E.g.
- VisualEditor should only register 'uls.data' if ULS extension isn't installed.
- The Math extension should only register its VE plugin if VE is installed.

Typically the dependency being checked is registered unconditionally. The
conditional one is the supplemental one in case the canonical source within
the MediaWiki landscape is absent.

Currently this means code will check both isModuleRegistered() and the global
$wgResourceModules. This doesn't make sense. Reverse this so that the
unconditional registry is processed first, and the programmatic one after.

This also helps exceptions come from a more sensible place in case of a duplicate
registration.

Change-Id: Ib2d01c88511ade75a97b2509bccfabb1a4cc5c15

includes/resourceloader/ResourceLoader.php

index 1886436..83ee8f9 100644 (file)
@@ -283,8 +283,8 @@ class ResourceLoader implements LoggerAwareInterface {
                $this->register( include "$IP/resources/Resources.php" );
                $this->register( include "$IP/resources/ResourcesOOUI.php" );
                // Register extension modules
-               Hooks::run( 'ResourceLoaderRegisterModules', array( &$this ) );
                $this->register( $config->get( 'ResourceModules' ) );
+               Hooks::run( 'ResourceLoaderRegisterModules', array( &$this ) );
 
                if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
                        $this->registerTestModules();