resourceloader: Move registration of Resources.php to ServiceWiring

This identified something we hadn't codified before which is that
we expect the 'startup' module to always exist. The code and tests
for ResourceLoaderClientHtml also assume this, which we now
acknowledge explicitly by leaving it in the constructor.

Bug: T32956
Change-Id: Iffc545eb32078aed0d059e5902a5c9382e14c641
This commit is contained in:
Timo Tijhof 2019-04-06 21:41:36 +01:00 committed by Krinkle
parent 9e1e44910e
commit 47422fabe2
3 changed files with 5 additions and 10 deletions

View file

@ -428,6 +428,7 @@ return [
},
'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader {
global $IP;
$config = $services->getMainConfig();
$rl = new ResourceLoader(
@ -435,6 +436,7 @@ return [
LoggerFactory::getInstance( 'resourceloader' )
);
$rl->addSource( $config->get( 'ResourceLoaderSources' ) );
$rl->register( include "$IP/resources/Resources.php" );
return $rl;
},

View file

@ -240,8 +240,6 @@ class ResourceLoader implements LoggerAwareInterface {
* @param LoggerInterface|null $logger [optional]
*/
public function __construct( Config $config = null, LoggerInterface $logger = null ) {
global $IP;
$this->logger = $logger ?: new NullLogger();
if ( !$config ) {
@ -254,8 +252,9 @@ class ResourceLoader implements LoggerAwareInterface {
// Add 'local' source first
$this->addSource( 'local', $config->get( 'LoadScript' ) );
// Register core modules
$this->register( include "$IP/resources/Resources.php" );
// Special module that always exists
$this->register( 'startup', [ 'class' => ResourceLoaderStartUpModule::class ] );
// Register extension modules
$this->register( $config->get( 'ResourceModules' ) );

View file

@ -27,12 +27,6 @@ if ( !defined( 'MEDIAWIKI' ) ) {
global $wgResourceBasePath;
return [
/**
* Special modules who have their own classes
*/
'startup' => [ 'class' => ResourceLoaderStartUpModule::class ],
// Scripts managed by the local wiki (stored in the MediaWiki namespace)
'site' => [ 'class' => ResourceLoaderSiteModule::class ],
'site.styles' => [ 'class' => ResourceLoaderSiteStylesModule::class ],