From: Timo Tijhof Date: Fri, 29 Mar 2019 01:21:18 +0000 (+0000) Subject: resourceloader: Move registering of custom sources to ServiceWiring X-Git-Tag: 1.34.0-rc.0~2254^2 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=5c90f8d137837cc6130c701fbd968855ab24a2d6;p=lhc%2Fweb%2Fwiklou.git resourceloader: Move registering of custom sources to ServiceWiring Remove the now-redundant mocking of this configuration from various test classes. Bug: T32956 Change-Id: If90a10a76b8289c4ba707382ac915441c17d831f --- diff --git a/includes/ServiceWiring.php b/includes/ServiceWiring.php index 73e4543a2a..b1cdc819e7 100644 --- a/includes/ServiceWiring.php +++ b/includes/ServiceWiring.php @@ -417,10 +417,15 @@ return [ }, 'ResourceLoader' => function ( MediaWikiServices $services ) : ResourceLoader { - return new ResourceLoader( - $services->getMainConfig(), + $config = $services->getMainConfig(); + + $rl = new ResourceLoader( + $config, LoggerFactory::getInstance( 'resourceloader' ) ); + $rl->addSource( $config->get( 'ResourceLoaderSources' ) ); + + return $rl; }, 'RevisionFactory' => function ( MediaWikiServices $services ) : RevisionFactory { diff --git a/includes/resourceloader/ResourceLoader.php b/includes/resourceloader/ResourceLoader.php index 5712692d6f..8ab7c0c2de 100644 --- a/includes/resourceloader/ResourceLoader.php +++ b/includes/resourceloader/ResourceLoader.php @@ -254,9 +254,6 @@ class ResourceLoader implements LoggerAwareInterface { // Add 'local' source first $this->addSource( 'local', $config->get( 'LoadScript' ) ); - // Add other sources - $this->addSource( $config->get( 'ResourceLoaderSources' ) ); - // Register core modules $this->register( include "$IP/resources/Resources.php" ); // Register extension modules diff --git a/tests/phpunit/ResourceLoaderTestCase.php b/tests/phpunit/ResourceLoaderTestCase.php index ca5ff6c549..c7fb48b6f3 100644 --- a/tests/phpunit/ResourceLoaderTestCase.php +++ b/tests/phpunit/ResourceLoaderTestCase.php @@ -60,9 +60,6 @@ abstract class ResourceLoaderTestCase extends MediaWikiTestCase { // Avoid influence from wgInvalidateCacheOnLocalSettingsChange 'CacheEpoch' => '20140101000000', - // For ResourceLoader::__construct() - 'ResourceLoaderSources' => [], - // For wfScript() 'ScriptPath' => '/w', 'Script' => '/w/index.php', diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php index 50b9421429..016679636f 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderClientHtmlTest.php @@ -17,7 +17,6 @@ class ResourceLoaderClientHtmlTest extends PHPUnit\Framework\TestCase { protected static function makeContext( $extraQuery = [] ) { $conf = new HashConfig( [ - 'ResourceLoaderSources' => [], 'ResourceModuleSkinStyles' => [], 'ResourceModules' => [], 'EnableJavaScriptTest' => false, diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php index 2ee85b5ee5..d4b5ed6c91 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php @@ -459,13 +459,12 @@ mw.loader.register( [ * @covers ResourceLoader::makeLoaderRegisterScript */ public function testGetModuleRegistrations( $case ) { - if ( isset( $case['sources'] ) ) { - $this->setMwGlobals( 'wgResourceLoaderSources', $case['sources'] ); - } - $extraQuery = $case['extraQuery'] ?? []; $context = $this->getResourceLoaderContext( $extraQuery ); $rl = $context->getResourceLoader(); + if ( isset( $case['sources'] ) ) { + $rl->addSource( $case['sources'] ); + } $rl->register( $case['modules'] ); $module = new ResourceLoaderStartUpModule(); $out = ltrim( $case['out'], "\n" ); diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index 5941c6eb82..3f7925f914 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -624,7 +624,6 @@ END * @covers ResourceLoader::getLoadScript */ public function testGetLoadScript() { - $this->setMwGlobals( 'wgResourceLoaderSources', [] ); $rl = new ResourceLoader(); $sources = self::fakeSources(); $rl->addSource( $sources );