Also restore the order of registrations as it was before
last week with
47422fabe2813f. (That is, core modules are registered
before extension modules, in case of conflicts with a warning, the
core one wins).
Bug: T32956
Change-Id: I3a50508178159dfc8e5db1e218a5e6d10e2d4b2a
$config,
LoggerFactory::getInstance( 'resourceloader' )
);
+
$rl->addSource( $config->get( 'ResourceLoaderSources' ) );
+
+ // Core modules, then extension/skin modules
$rl->register( include "$IP/resources/Resources.php" );
+ $rl->register( $config->get( 'ResourceModules' ) );
+ Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
+
+ if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
+ $rl->registerTestModules();
+ }
return $rl;
},
// Special module that always exists
$this->register( 'startup', [ 'class' => ResourceLoaderStartUpModule::class ] );
- // Register extension modules
- $this->register( $config->get( 'ResourceModules' ) );
-
- // Avoid PHP 7.1 warning from passing $this by reference
- $rl = $this;
- Hooks::run( 'ResourceLoaderRegisterModules', [ &$rl ] );
-
- if ( $config->get( 'EnableJavaScriptTest' ) === true ) {
- $this->registerTestModules();
- }
-
$this->setMessageBlobStore( new MessageBlobStore( $this, $this->logger ) );
}
}
}
+ /**
+ * @internal For use by ServiceWiring only
+ */
public function registerTestModules() {
global $IP;
<?php
use Wikimedia\TestingAccessWrapper;
+use MediaWiki\MediaWikiServices;
class ResourceLoaderTest extends ResourceLoaderTestCase {
/**
* Ensure the ResourceLoaderRegisterModules hook is called.
- *
- * @covers ResourceLoader::__construct
+ * @coversNothing
*/
- public function testConstructRegistrationHook() {
- $resourceLoaderRegisterModulesHook = false;
+ public function testServiceWiring() {
+ $this->overrideMwServices();
+ $ranHook = 0;
$this->setMwGlobals( 'wgHooks', [
'ResourceLoaderRegisterModules' => [
- function ( &$resourceLoader ) use ( &$resourceLoaderRegisterModulesHook ) {
- $resourceLoaderRegisterModulesHook = true;
+ function ( &$resourceLoader ) use ( &$ranHook ) {
+ $ranHook++;
}
]
] );
- $unused = new ResourceLoader();
- $this->assertTrue(
- $resourceLoaderRegisterModulesHook,
- 'Hook ResourceLoaderRegisterModules called'
- );
+ MediaWikiServices::getInstance()->getResourceLoader();
+
+ $this->assertSame( 1, $ranHook, 'Hook was called' );
}
/**