Don't cache $wgResourceLoaderLESSVars in a static
authorOri Livneh <ori@wikimedia.org>
Fri, 18 Apr 2014 19:11:42 +0000 (12:11 -0700)
committerOri Livneh <ori@wikimedia.org>
Fri, 18 Apr 2014 19:11:42 +0000 (12:11 -0700)
Caching the value of $wgResourceLoaderLESSVars in a static variable that is
enclosed in a closure makes it harder to reset global state for test runs, and
it does so in the name of a performance benefit that is miniscule.

Change-Id: I0958b03818f56ab73c8c9124daa9e54cc59f2428

includes/resourceloader/ResourceLoader.php

index eac6a02..6b8c7c4 100644 (file)
@@ -1319,12 +1319,9 @@ class ResourceLoader {
        public static function getLESSVars() {
                global $wgResourceLoaderLESSVars;
 
-               static $lessVars = null;
-               if ( $lessVars === null ) {
-                       $lessVars = $wgResourceLoaderLESSVars;
-                       // Sort by key to ensure consistent hashing for cache lookups.
-                       ksort( $lessVars );
-               }
+               $lessVars = $wgResourceLoaderLESSVars;
+               // Sort by key to ensure consistent hashing for cache lookups.
+               ksort( $lessVars );
                return $lessVars;
        }
 }