From: jenkins-bot Date: Sat, 23 Aug 2014 00:43:07 +0000 (+0000) Subject: Merge "ResourceLoaderFileModule: Do not separately cache .less files" X-Git-Tag: 1.31.0-rc.0~14307 X-Git-Url: http://git.heureux-cyclage.org/?a=commitdiff_plain;h=86c94c36f076a3c736d333129b2f311551a02cf3;hp=05047791f1b0b95c2ac92ed96f16f550a81b17a2;p=lhc%2Fweb%2Fwiklou.git Merge "ResourceLoaderFileModule: Do not separately cache .less files" --- diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index 9fdeb91ba0..0c84700ece 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -898,61 +898,20 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { return $this->targets; } - /** - * Generate a cache key for a LESS file. - * - * The cache key varies on the file name and the names and values of global - * LESS variables. - * - * @since 1.22 - * @param string $fileName File name of root LESS file. - * @return string Cache key - */ - protected function getLessCacheKey( $fileName ) { - $vars = json_encode( ResourceLoader::getLessVars( $this->getConfig() ) ); - $hash = md5( $fileName . $vars ); - return wfMemcKey( 'resourceloader', 'less', $hash ); - } - /** * Compile a LESS file into CSS. * - * If invalid, returns replacement CSS source consisting of the compilation - * error message encoded as a comment. To save work, we cache a result object - * which comprises the compiled CSS and the names & mtimes of the files - * that were processed. lessphp compares the cached & current mtimes and - * recompiles as necessary. + * Keeps track of all used files and adds them to localFileRefs. * * @since 1.22 - * @throws Exception If Less encounters a parse error - * @throws MWException If Less compilation returns unexpection result + * @throws Exception If lessc encounters a parse error * @param string $fileName File path of LESS source * @return string CSS source */ protected function compileLessFile( $fileName ) { - $key = $this->getLessCacheKey( $fileName ); - $cache = wfGetCache( CACHE_ANYTHING ); - - // The input to lessc. Either an associative array representing the - // cached results of a previous compilation, or the string file name if - // no cache result exists. - $source = $cache->get( $key ); - if ( !is_array( $source ) || !isset( $source['root'] ) ) { - $source = $fileName; - } - $compiler = ResourceLoader::getLessCompiler( $this->getConfig() ); - $result = null; - - $result = $compiler->cachedCompile( $source ); - - if ( !is_array( $result ) ) { - throw new MWException( 'LESS compiler result has type ' - . gettype( $result ) . '; array expected.' ); - } - - $this->localFileRefs += array_keys( $result['files'] ); - $cache->set( $key, $result ); - return $result['compiled']; + $result = $compiler->compileFile( $fileName ); + $this->localFileRefs += array_keys( $compiler->allParsedFiles() ); + return $result; } }