resourceloader: Move remaining module registrations to ServiceWiring
Also restore the order of registrations as it was before
last week with 47422fabe2. (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
This commit is contained in:
parent
63591baccc
commit
a259a2ed0d
3 changed files with 22 additions and 22 deletions
|
|
@ -443,8 +443,17 @@ return [
|
|||
$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;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -255,17 +255,6 @@ class ResourceLoader implements LoggerAwareInterface {
|
|||
// 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 ) );
|
||||
}
|
||||
|
||||
|
|
@ -394,6 +383,9 @@ class ResourceLoader implements LoggerAwareInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal For use by ServiceWiring only
|
||||
*/
|
||||
public function registerTestModules() {
|
||||
global $IP;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Wikimedia\TestingAccessWrapper;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
||||
class ResourceLoaderTest extends ResourceLoaderTestCase {
|
||||
|
||||
|
|
@ -14,25 +15,23 @@ 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' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue