From aac831f9fafef05c6958c710fe739ea0f323e84a Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 16 Jun 2015 04:57:12 +0100 Subject: [PATCH] resourceloader: Use content-neutral context when computing module versions The startup module produces a manifest with versions representing the entire module. Typically, the request for the startup module itself has only=scripts. However, that "only" must only apply to what resources of the startup module are output in the request. The context passed to getModifiedTime() and getVersionHash() must not suggest any restriction of measuring only the scripts, or otherwise ignoring some aspects of the module (such as stylesheets, or messages). Most existing getModifiedTime() implementations compute timestamps of all files, regardless of the context. So this bug didn't surface before. However that will change for modules that compute the version hash based on getModuleContent(), which does honour the getOnly() and shouldIncludeScripts() methods of the request context. Change-Id: Ib8f09c39d10724d146b53b6d53d82da18944a12b --- includes/resourceloader/ResourceLoaderModule.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/includes/resourceloader/ResourceLoaderModule.php b/includes/resourceloader/ResourceLoaderModule.php index 63da59245b..d58c01d000 100644 --- a/includes/resourceloader/ResourceLoaderModule.php +++ b/includes/resourceloader/ResourceLoaderModule.php @@ -585,6 +585,16 @@ abstract class ResourceLoaderModule { * @return string Hash (should use ResourceLoader::makeHash) */ public function getVersionHash( ResourceLoaderContext $context ) { + // The startup module produces a manifest with versions representing the entire module. + // Typically, the request for the startup module itself has only=scripts. That must apply + // only to the startup module content, and not to the module version computed here. + $context = new DerivativeResourceLoaderContext( $context ); + $context->setModules( array() ); + // Version hash must cover all resources, regardless of startup request itself. + $context->setOnly( null ); + // Compute version hash based on content, not debug urls. + $context->setDebug( false ); + // Cache this somewhat expensive operation. Especially because some classes // (e.g. startup module) iterate more than once over all modules to get versions. $contextHash = $context->getHash(); -- 2.20.1