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
This commit is contained in:
parent
f371574b79
commit
aac831f9fa
1 changed files with 10 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue