resourceloader: Fix undefined variable in ResourceLoaderFileModule::getSkipFunction
[lhc/web/wiklou.git] / includes / resourceloader / ResourceLoaderFileModule.php
index edde9bc..06f7146 100644 (file)
@@ -292,7 +292,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         *     to $IP
         * @param string $remoteBasePath Path to use if not provided in module definition. Defaults
         *     to $wgScriptPath
-        * @return array array( localBasePath, remoteBasePath )
+        * @return array Array( localBasePath, remoteBasePath )
         */
        public static function extractBasePaths(
                $options = array(),
@@ -305,9 +305,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                // but were preserved for backwards-compatibility just in case. Tread lightly.
 
                $localBasePath = $localBasePath === null ? $IP : $localBasePath;
-               if ( $remoteBasePath !== null ) {
-                       $remoteBasePath = $remoteBasePath;
-               } else {
+               if ( $remoteBasePath === null ) {
                        $remoteBasePath = $wgResourceBasePath === null ? $wgScriptPath : $wgResourceBasePath;
                }
 
@@ -475,14 +473,13 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                        return null;
                }
 
-               global $wgResourceLoaderValidateStaticJS;
                $localPath = $this->getLocalPath( $this->skipFunction );
                if ( !file_exists( $localPath ) ) {
                        throw new MWException( __METHOD__ . ": skip function file not found: \"$localPath\"" );
                }
                $contents = file_get_contents( $localPath );
-               if ( $wgResourceLoaderValidateStaticJS ) {
-                       $contents = $this->validateScriptFile( $fileName, $contents );
+               if ( $this->getConfig()->get( 'ResourceLoaderValidateStaticJS' ) ) {
+                       $contents = $this->validateScriptFile( $localPath, $contents );
                }
                return $contents;
        }
@@ -792,7 +789,6 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @return string Concatenated and remapped JavaScript data from $scripts
         */
        protected function readScriptFiles( array $scripts ) {
-               global $wgResourceLoaderValidateStaticJS;
                if ( empty( $scripts ) ) {
                        return '';
                }
@@ -803,7 +799,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                                throw new MWException( __METHOD__ . ": script file not found: \"$localPath\"" );
                        }
                        $contents = file_get_contents( $localPath );
-                       if ( $wgResourceLoaderValidateStaticJS ) {
+                       if ( $this->getConfig()->get( 'ResourceLoaderValidateStaticJS' ) ) {
                                // Static files don't really need to be checked as often; unlike
                                // on-wiki module they shouldn't change unexpectedly without
                                // admin interference.
@@ -911,8 +907,8 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @param string $fileName File name of root LESS file.
         * @return string Cache key
         */
-       protected static function getLESSCacheKey( $fileName ) {
-               $vars = json_encode( ResourceLoader::getLESSVars() );
+       protected function getLESSCacheKey( $fileName ) {
+               $vars = json_encode( ResourceLoader::getLESSVars( $this->getConfig() ) );
                $hash = md5( $fileName . $vars );
                return wfMemcKey( 'resourceloader', 'less', $hash );
        }
@@ -933,7 +929,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
         * @return string CSS source
         */
        protected function compileLESSFile( $fileName ) {
-               $key = self::getLESSCacheKey( $fileName );
+               $key = $this->getLESSCacheKey( $fileName );
                $cache = wfGetCache( CACHE_ANYTHING );
 
                // The input to lessc. Either an associative array representing the
@@ -944,7 +940,7 @@ class ResourceLoaderFileModule extends ResourceLoaderModule {
                        $source = $fileName;
                }
 
-               $compiler = ResourceLoader::getLessCompiler();
+               $compiler = ResourceLoader::getLessCompiler( $this->getConfig() );
                $result = null;
 
                $result = $compiler->cachedCompile( $source );