* (T140807) The wgResourceLoaderLESSImportPaths configuration option was removed
from ResourceLoader. Instead, use `@import` statements in LESS to import
files directly from nearby directories within the same project.
+* (T140804) The wgResourceLoaderLESSVars configuration option, deprecated
+ since 1.30, was removed. Instead, to expose variables from PHP to LESS, use
+ the ResourceLoaderModule::getLessVars() method.
* The protected methods PHPSessionHandler::returnSuccess() and returnFailure(),
only needed for PHP5 compatibility, have been removed. It now uses the boolean
values `true` and `false` respectively.
"type": "object",
"description": "ResourceLoader sources to register"
},
- "ResourceLoaderLESSVars": {
- "type": "object",
- "description": "ResourceLoader LESS variables"
- },
"ConfigRegistry": {
"type": "object",
"description": "Registry of factory functions to create Config objects"
"type": "object",
"description": "ResourceLoader sources to register"
},
- "ResourceLoaderLESSVars": {
- "type": "object",
- "description": "ResourceLoader LESS variables"
- },
"ConfigRegistry": {
"type": "object",
"description": "Registry of factory functions to create Config objects"
*/
$wgResourceLoaderValidateStaticJS = false;
-/**
- * Global LESS variables. An associative array binding variable names to
- * LESS code snippets representing their values.
- *
- * Adding an item here is equivalent to writing `@variable: value;`
- * at the beginning of all your .less files, with all the consequences.
- * In particular, string values must be escaped and quoted.
- *
- * Changes to this configuration do NOT trigger cache invalidation.
- *
- * @par Example:
- * @code
- * $wgResourceLoaderLESSVars = [
- * 'exampleFontSize' => '1em',
- * 'exampleBlue' => '#36c',
- * ];
- * @endcode
- * @since 1.22
- * @deprecated since 1.30 Use ResourceLoaderModule::getLessVars() instead to
- * add variables to individual modules that need them.
- */
-$wgResourceLoaderLESSVars = [
- /**
- * Minimum available screen width at which a device can be considered a tablet
- * The number is currently based on the device width of a Samsung Galaxy S5 mini and is low
- * enough to cover iPad (768px). Number is prone to change with new information.
- * @since 1.27
- * @deprecated 1.31 Use mediawiki.ui/variables instead
- */
- 'deviceWidthTablet' => '720px',
-];
-
/**
* Whether ResourceLoader should attempt to persist modules in localStorage on
* browsers that support the Web Storage API.
'RecentChangesFlags',
'RemoveCredentialsBlacklist',
'RemoveGroups',
- 'ResourceLoaderLESSVars',
'ResourceLoaderSources',
'RevokePermissions',
'SessionProviders',
/** @var bool */
protected static $debugMode = null;
- /** @var array */
- private $lessVars = null;
-
/**
* Module name/ResourceLoaderModule object pairs
* @var array
* Get global LESS variables.
*
* @since 1.27
+ * @deprecated since 1.32 Use ResourceLoderModule::getLessVars() instead.
* @return array Map of variable names to string CSS values.
*/
public function getLessVars() {
- if ( $this->lessVars === null ) {
- $this->lessVars = $this->config->get( 'ResourceLoaderLESSVars' );
- }
- return $this->lessVars;
+ return [];
}
}
$cache = ObjectCache::getLocalServerInstance( CACHE_ANYTHING );
}
- $vars = array_merge(
- $context->getResourceLoader()->getLessVars(),
- $this->getLessVars( $context )
- );
+ $vars = $this->getLessVars( $context );
// Construct a cache key from the LESS file name, and a hash digest
// of the LESS variables used for compilation.
ksort( $vars );
);
}
+ /**
+ * @covers ResourceLoaderFileModule::compileLessFile
+ */
+ public function testLessFileCompilation() {
+ $context = $this->getResourceLoaderContext();
+ $basePath = __DIR__ . '/../../data/less/module';
+ $module = new ResourceLoaderFileTestModule( [
+ 'localBasePath' => $basePath,
+ 'styles' => [ 'styles.less' ],
+ ], [
+ 'lessVars' => [ 'foo' => '2px', 'Foo' => '#eeeeee' ]
+ ] );
+ $module->setName( 'test.less' );
+ $styles = $module->getStyles( $context );
+ $this->assertStringEqualsFile( $basePath . '/styles.css', $styles['all'] );
+ }
+
/**
* @covers ResourceLoaderFileModule::getDefinitionSummary
* @covers ResourceLoaderFileModule::getFileHashes
parent::setUp();
$this->setMwGlobals( [
- 'wgResourceLoaderLESSVars' => [
- 'foo' => '2px',
- 'Foo' => '#eeeeee',
- 'bar' => 5,
- ],
- // Clear ResourceLoaderGetConfigVars hooks (called by StartupModule)
- // to avoid notices during testMakeModuleResponse for missing
- // wgResourceLoaderLESSVars keys in extension hooks.
- 'wgHooks' => [],
'wgShowExceptionDetails' => true,
] );
}
);
}
- /**
- * @covers ResourceLoaderFileModule::compileLessFile
- */
- public function testLessFileCompilation() {
- $context = $this->getResourceLoaderContext();
- $basePath = __DIR__ . '/../../data/less/module';
- $module = new ResourceLoaderFileModule( [
- 'localBasePath' => $basePath,
- 'styles' => [ 'styles.less' ],
- ] );
- $module->setName( 'test.less' );
- $styles = $module->getStyles( $context );
- $this->assertStringEqualsFile( $basePath . '/styles.css', $styles['all'] );
- }
-
/**
* @covers ResourceLoader::getLessCompiler
*/
public function testLessImportDirs() {
$rl = new EmptyResourceLoader();
- $lc = $rl->getLessCompiler( $rl->getLessVars() );
+ $lc = $rl->getLessCompiler( [ 'foo' => '2px', 'Foo' => '#eeeeee' ] );
$basePath = dirname( dirname( __DIR__ ) ) . '/data/less';
$lc->SetImportDirs( [
"$basePath/common" => '',