Skip to content

Commit 8f52cb8

Browse files
KrinkleMatmaRex
authored andcommitted
resourceloader: Soft-deprecate use of global LESS variables
Add deprecation notice to $wgResourceLoaderLESSVars and hook 'ResourceLoaderGetLessVars'. Warnings to be added in 1.31. Users should migrate to exposing variables via the individual module's getLessVars() method. - Ensures better cache invalidation. - Separates concerns for getting information and exposing information as less variables. And allows an extension to, for example, use a different variable name for something if needed. The 'deviceWidthTablet' variable will need to be migrated to either a regular configuration variable that individual modules can expose in their getLessVars() method - or, alternatively, we can deprecate it altogether in favour of exposing it through a less import file instead (see T112747). That would mean, however, that the value can only be changed in core, not by site config. Bug: T140804 Change-Id: I61cff1d9652d88dc53c43075dd5053b7707809e6
1 parent 057f441 commit 8f52cb8

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

docs/hooks.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,9 +2764,10 @@ configuration variables to JavaScript. Things that depend on the current page
27642764
or request state must be added through MakeGlobalVariablesScript instead.
27652765
&$vars: array( variable name => value )
27662766

2767-
'ResourceLoaderGetLessVars': Called in ResourceLoader::getLessVars after
2768-
variables from $wgResourceLoaderLESSVars are added. Can be used to add
2769-
context-based variables.
2767+
'ResourceLoaderGetLessVars': DEPRECATED! Called in ResourceLoader::getLessVars
2768+
to add global LESS variables. Loaded after $wgResourceLoaderLESSVars is added.
2769+
Global LESS variables are deprecated. Use ResourceLoaderModule::getLessVars()
2770+
instead to expose variables only in modules that need them.
27702771
&$lessVars: array of variables already added
27712772

27722773
'ResourceLoaderJqueryMsgModuleMagicWords': Called in

includes/DefaultSettings.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,20 +3754,18 @@
37543754
* at the beginning of all your .less files, with all the consequences.
37553755
* In particular, string values must be escaped and quoted.
37563756
*
3757-
* Changes to LESS variables do not trigger cache invalidation.
3758-
*
3759-
* If the LESS variables need to be dynamic, you can use the
3760-
* ResourceLoaderGetLessVars hook (since 1.25).
3757+
* Changes to this configuration do NOT trigger cache invalidation.
37613758
*
37623759
* @par Example:
37633760
* @code
37643761
* $wgResourceLoaderLESSVars = [
3765-
* 'baseFontSize' => '1em',
3766-
* 'smallFontSize' => '0.75em',
3767-
* 'WikimediaBlue' => '#006699',
3762+
* 'exampleFontSize' => '1em',
3763+
* 'exampleBlue' => '#eee',
37683764
* ];
37693765
* @endcode
37703766
* @since 1.22
3767+
* @deprecated since 1.30 Use ResourceLoaderModule::getLessVars() instead to
3768+
* add variables to individual modules that need them.
37713769
*/
37723770
$wgResourceLoaderLESSVars = [
37733771
/**

0 commit comments

Comments
 (0)