From: Timo Tijhof Date: Thu, 1 Aug 2019 00:19:45 +0000 (+0100) Subject: resourceloader: Remove slow structure test for checking getVersionHash X-Git-Tag: 1.34.0-rc.0~818^2 X-Git-Url: http://git.cyclocoop.org/data/%24self?a=commitdiff_plain;h=8199e028fd1dd7a2b55f9f63951ea785cd6c68cd;p=lhc%2Fweb%2Fwiklou.git resourceloader: Remove slow structure test for checking getVersionHash This isn't needed because the startup module validates this already. The vast majority of modules are FileModule instances which can't be invalid, because a separate test asserts that class already. This test existed for validating the format of version hashes returned by a theoretical Module sub class in an extension that (badly) overrides the getVersionHash method. As of writing, no extension overrides that method. And more importantly, the startup module already validates this at run-time, and logs a warning. This commit turns that into an exception, which would get logged in a way that Jenkins will fail the build if encountered. This structure test, which computed the response for all registered modules, previously took 3-5 seconds in CI. Bug: T225730 Change-Id: Id2e37434b0ccd95dd2279f04e2230e9c06b09ccb --- diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 6b38ee4cf7..dbf6b2130b 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -283,8 +283,9 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { } if ( $versionHash !== '' && strlen( $versionHash ) !== 7 ) { - $this->getLogger()->warning( - "Module '{module}' produced an invalid version hash: '{version}'.", + $e = new RuntimeException( "Badly formatted module version hash" ); + $resourceLoader->outputErrorAndLog( $e, + "Module '{module}' produced an invalid version hash: '{version}'.", [ 'module' => $name, 'version' => $versionHash, diff --git a/tests/phpunit/structure/ResourcesTest.php b/tests/phpunit/structure/ResourcesTest.php index 4f9664f4ca..acd8a198bd 100644 --- a/tests/phpunit/structure/ResourcesTest.php +++ b/tests/phpunit/structure/ResourcesTest.php @@ -36,14 +36,6 @@ class ResourcesTest extends MediaWikiTestCase { ); } - public function testVersionHash() { - $data = self::getAllModules(); - foreach ( $data['modules'] as $moduleName => $module ) { - $version = $module->getVersionHash( $data['context'] ); - $this->assertEquals( 7, strlen( $version ), "$moduleName must use ResourceLoader::makeHash" ); - } - } - /** * Verify that all modules specified as dependencies of other modules actually * exist and are not illegal.