From: Timo Tijhof Date: Thu, 20 Mar 2014 04:32:30 +0000 (+0100) Subject: ResourceLoaderStartUpModule: Improve comment about modifiedTime hack X-Git-Tag: 1.31.0-rc.0~16469^2~1 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=45ffc8c937ff44716f8bc96b608410b57998a77b;p=lhc%2Fweb%2Fwiklou.git ResourceLoaderStartUpModule: Improve comment about modifiedTime hack * Re-ordering code to bring the modifiedTime hack and the loop it serves closer together. * Separating the fact that it needs a value and the mtime of startup.js since that is just one of the three factors we use. This way it's clearer that the startup.js mtime is not just a bogus value, but not more or less important than wgCacheEpoch and modules mtime either. * Remove duplicate '/* Methods */' comment, we already have this marker a few methods higher up. Change-Id: Id3a07f02566c0f04b612b81f8353f70fa4ab3977 --- diff --git a/includes/resourceloader/ResourceLoaderStartUpModule.php b/includes/resourceloader/ResourceLoaderStartUpModule.php index 3482bfad75..a551c4ae0d 100644 --- a/includes/resourceloader/ResourceLoaderStartUpModule.php +++ b/includes/resourceloader/ResourceLoaderStartUpModule.php @@ -276,21 +276,27 @@ class ResourceLoaderStartUpModule extends ResourceLoaderModule { $loader = $context->getResourceLoader(); $loader->preloadModuleInfo( $loader->getModuleNames(), $context ); - $this->modifiedTime[$hash] = filemtime( "$IP/resources/startup.js" ); - // ATTENTION!: Because of the line above, this is not going to cause + $time = max( + wfTimestamp( TS_UNIX, $wgCacheEpoch ), + filemtime( "$IP/resources/startup.js" ) + ); + + // ATTENTION!: Because of the line below, this is not going to cause // infinite recursion - think carefully before making changes to this // code! - $time = wfTimestamp( TS_UNIX, $wgCacheEpoch ); + // Pre-populate modifiedTime with something because the the loop over + // all modules below includes the the startup module (this module). + $this->modifiedTime[$hash] = 1; + foreach ( $loader->getModuleNames() as $name ) { $module = $loader->getModule( $name ); $time = max( $time, $module->getModifiedTime( $context ) ); } + $this->modifiedTime[$hash] = $time; return $this->modifiedTime[$hash]; } - /* Methods */ - /** * @return string */