ResourceLoaderStartUpModule: Improve comment about modifiedTime hack
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 20 Mar 2014 04:32:30 +0000 (05:32 +0100)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 20 Mar 2014 04:34:21 +0000 (05:34 +0100)
* 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

includes/resourceloader/ResourceLoaderStartUpModule.php

index 3482bfa..a551c4a 100644 (file)
@@ -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
         */