resourceloader: Move registration of Resources.php to ServiceWiring
authorTimo Tijhof <krinklemail@gmail.com>
Sat, 6 Apr 2019 20:41:36 +0000 (21:41 +0100)
committerKrinkle <krinklemail@gmail.com>
Sat, 6 Apr 2019 23:35:58 +0000 (23:35 +0000)
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

includes/ServiceWiring.php
includes/resourceloader/ResourceLoader.php
resources/Resources.php

index cccb5e7..0b5288e 100644 (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;
        },
index 4cf8735..b8569d4 100644 (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' ) );
 
index af40b73..cde4721 100644 (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 ],