From: Timo Tijhof Date: Sat, 6 Apr 2019 20:41:36 +0000 (+0100) Subject: resourceloader: Move registration of Resources.php to ServiceWiring X-Git-Tag: 1.34.0-rc.0~2105^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=47422fabe2813fb12b7663257924fdf4cd7cd0d1;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index cccb5e733f..0b5288ee5f 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -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; }, diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 4cf87350dd..b8569d4515 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -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' ) ); diff --git a/resources/Resources.php b/resources/Resources.php index af40b731d9..cde47217b6 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 ],