aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
diff options
context:
space:
mode:
authorTimo Tijhof <krinklemail@gmail.com>2018-08-30 02:42:24 +0100
committerAaron Schulz <aschulz@wikimedia.org>2018-08-30 21:02:57 +0000
commite42837e97753cd5e03a8dbab865c3ca8a6bcfb93 (patch)
tree1f4cad79e16ea5589d53e292bd4d823780e7c113 /tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
parentfede766fe9950e3a036c263bf17d19d31278221c (diff)
downloadmediawikicore-e42837e97753cd5e03a8dbab865c3ca8a6bcfb93.tar.gz
mediawikicore-e42837e97753cd5e03a8dbab865c3ca8a6bcfb93.zip
resourceloader: Remove selective build optimisation from getModuleContent()
This follows 5ddd7f91c7, which factored out response building from ResourceLoader.php to ResourceLoaderModule::buildContent. As optimisation, I made this method only return the array keys needed for the current response; based $context->getOnly(). The reason for this refactoring was the creation of the 'enableModuleContentVersion' option to getVersionHash(), which would use this method to create a module response, and hash it. During the implementation of that option, I ran into a problem. getVersionHash() is called by the startup module for each registered module, to create the manifest. The context for the StartupModule request itself has "only=scripts". But, we must still compute the version hashes for whole modules, not just their scripts. I worked around that problem in aac831f9fa by creating a mock context in getVersionHash() that stubs out the 'only' parameter. This worked, but made the assumption that the scripts and styles of a module cannot differ based on the 'only' parameter. This assumption was wrong, because the 'only' parameter is part of ResourceLoaderContext and available to all getters to vary on. Fortunately, the 'enableModuleContentVersion' option is off by default and nobody currently using it was differing its output by the 'only' parameter. I intend to make use of the 'enableModuleContentVersion' option in StartupModule to fix T201686. And StartupModule outputs a manifest if the request specifies only=scripts, and outputs a warning otherwise. As such, it cannot compute its version if the 'only' parameter is stubbed out. * Remove the 'only' parameter stubbing. * Remove the selective building from the buildContent() method. This was not very useful because we need to build the whole module regardless when computing the version. As benefit, this means the in-process cache is now shared between the call from getVersionHash and the call from makeModuleResponse. Bug: T201686 Change-Id: I8a17888f95f86ac795bc2de43086225b8a8f4b78
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php')
-rw-r--r--tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
index c9253392cbe6..0c707d55375f 100644
--- a/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderModuleTest.php
@@ -151,8 +151,8 @@ class ResourceLoaderModuleTest extends ResourceLoaderTestCase {
] );
$this->assertEquals( $raw, $module->getScript( $context ), 'Raw script' );
$this->assertEquals(
- [ 'scripts' => $build ],
- $module->getModuleContent( $context ),
+ $build,
+ $module->getModuleContent( $context )[ 'scripts' ],
$message
);
}