$context
);
// Collect referenced files
- $this->localFileRefs = array_unique( $this->localFileRefs );
- $this->saveFileDependencies( $context->getSkin(), $this->localFileRefs );
+ $this->saveFileDependencies( $context, $this->localFileRefs );
return $styles;
}
}
$files = array_map( array( $this, 'getLocalPath' ), $files );
// File deps need to be treated separately because they're already prefixed
- $files = array_merge( $files, $this->getFileDependencies( $context->getSkin() ) );
+ $files = array_merge( $files, $this->getFileDependencies( $context ) );
// Filter out any duplicates from getFileDependencies() and others.
// Most commonly introduced by compileLessFile(), which always includes the
// entry point Less file we already know about.
* @param array $styles List of media type/list of file paths pairs, to read, remap and
* concetenate
* @param bool $flip
- * @param ResourceLoaderContext $context (optional)
+ * @param ResourceLoaderContext $context
*
* @throws MWException
* @return array List of concatenated and remapped CSS data from $styles,
* keyed by media type
+ *
+ * @since 1.26 Calling this method without a ResourceLoaderContext instance
+ * is deprecated.
*/
public function readStyleFiles( array $styles, $flip, $context = null ) {
+ if ( $context === null ) {
+ wfDeprecated( __METHOD__ . ' without a ResourceLoader context', '1.26' );
+ $context = ResourceLoaderContext::newDummyContext();
+ }
+
if ( empty( $styles ) ) {
return array();
}
*
* @param string $path File path of style file to read
* @param bool $flip
- * @param ResourceLoaderContext $context (optional)
+ * @param ResourceLoaderContext $context
*
* @return string CSS data in script file
* @throws MWException If the file doesn't exist
*/
- protected function readStyleFile( $path, $flip, $context = null ) {
+ protected function readStyleFile( $path, $flip, $context ) {
$localPath = $this->getLocalPath( $path );
$remotePath = $this->getRemotePath( $path );
if ( !file_exists( $localPath ) ) {
}
if ( $this->getStyleSheetLang( $localPath ) === 'less' ) {
- $compiler = $this->getLessCompiler( $context );
- $style = $this->compileLessFile( $localPath, $compiler );
+ $style = $this->compileLessFile( $localPath, $context );
$this->hasGeneratedStyles = true;
} else {
$style = file_get_contents( $localPath );
* Keeps track of all used files and adds them to localFileRefs.
*
* @since 1.22
+ * @since 1.26 Added $context paramter.
* @throws Exception If less.php encounters a parse error
* @param string $fileName File path of LESS source
- * @param Less_Parser $parser Compiler to use, if not default
+ * @param ResourceLoaderContext $context Context in which to generate script
* @return string CSS source
*/
- protected function compileLessFile( $fileName, $compiler = null ) {
+ protected function compileLessFile( $fileName, ResourceLoaderContext $context ) {
static $cache;
if ( !$cache ) {
// Construct a cache key from the LESS file name and a hash digest
// of the LESS variables used for compilation.
- $varsHash = hash( 'md4', serialize( ResourceLoader::getLessVars( $this->getConfig() ) ) );
+ $vars = $this->getLessVars( $context );
+ ksort( $vars );
+ $varsHash = hash( 'md4', serialize( $vars ) );
$cacheKey = wfGlobalCacheKey( 'LESS', $fileName, $varsHash );
$cachedCompile = $cache->get( $cacheKey );
}
}
- if ( !$compiler ) {
- $compiler = $this->getLessCompiler();
- }
-
+ $compiler = ResourceLoader::getLessCompiler( $this->getConfig(), $vars );
$css = $compiler->parseFile( $fileName )->getCss();
$files = $compiler->AllParsedFiles();
$this->localFileRefs = array_merge( $this->localFileRefs, $files );
return $css;
}
- /**
- * Get a LESS compiler instance for this module in given context.
- *
- * Just calls ResourceLoader::getLessCompiler() by default to get a global compiler.
- *
- * @param ResourceLoaderContext $context
- * @throws MWException
- * @since 1.24
- * @return Less_Parser
- */
- protected function getLessCompiler( ResourceLoaderContext $context = null ) {
- return ResourceLoader::getLessCompiler( $this->getConfig() );
- }
-
/**
* Takes named templates by the module and returns an array mapping.
* @return array of templates mapping template alias to content