Merge "includes/resourceloader/: Use Config instead of globals"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 8 Aug 2014 17:25:42 +0000 (17:25 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 8 Aug 2014 17:25:42 +0000 (17:25 +0000)
1  2 
docs/hooks.txt
includes/resourceloader/ResourceLoaderFileModule.php

diff --combined docs/hooks.txt
@@@ -2148,7 -2148,7 +2148,7 @@@ $oldSessionID: old session i
  $newSessionID: new session id
  
  'ResourceLoaderGetConfigVars': Called at the end of
- ResourceLoaderStartUpModule::getConfig(). Use this to export static
+ ResourceLoaderStartUpModule::getConfigSettings(). Use this to export static
  configuration variables to JavaScript. Things that depend on the current page
  or request state must be added through MakeGlobalVariablesScript instead.
  &$vars: array( variable name => value )
@@@ -2734,11 -2734,11 +2734,11 @@@ string &$error: output: message key fo
    returning false. May also be an array, where the first element is the message
    key and the remaining elements are used as parameters to the message.
  
 -'UploadVerifyFile': extra file verification, based on mime type, etc. Preferred
 +'UploadVerifyFile': extra file verification, based on MIME type, etc. Preferred
  in most cases over UploadVerification.
  object $upload: an instance of UploadBase, with all info about the upload
 -string $mime: The uploaded file's mime type, as detected by MediaWiki. Handlers
 -  will typically only apply for specific mime types.
 +string $mime: The uploaded file's MIME type, as detected by MediaWiki. Handlers
 +  will typically only apply for specific MIME types.
  object &$error: output: true if the file is valid. Otherwise, an indexed array
    representing the problem with the file, where the first element is the message
    key and the remaining elements are used as parameters to the message.
@@@ -305,7 -305,9 +305,7 @@@ class ResourceLoaderFileModule extends 
                // 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;
                }
  
                        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 ) {
+               if ( $this->getConfig()->get( 'ResourceLoaderValidateStaticJS' ) ) {
                        $contents = $this->validateScriptFile( $fileName, $contents );
                }
                return $contents;
         * @return string Concatenated and remapped JavaScript data from $scripts
         */
        protected function readScriptFiles( array $scripts ) {
-               global $wgResourceLoaderValidateStaticJS;
                if ( empty( $scripts ) ) {
                        return '';
                }
                                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.
         * @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 );
        }
         * @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
                        $source = $fileName;
                }
  
-               $compiler = ResourceLoader::getLessCompiler();
+               $compiler = ResourceLoader::getLessCompiler( $this->getConfig() );
                $result = null;
  
                $result = $compiler->cachedCompile( $source );