lessphp
lessphp copied to clipboard
Latest version getting lots of issues
Hi there we just upgraded to the latest version and are getting lots of issues... seems like there are some new checks that happen for color variables... ie
expected color value errors occur... the code compiled fine before but now these errors are nested within other files... there is no specific line numbers... so on a file such as
@import '../../core/assets/css/bootstrap/reset.less'; @import 'config.less'; @import 'brand.less'; @import 'variables.less'; @import 'scaffolding.less'; @import '../../core/assets/css/core_mixins.less'; @import '../../core/assets/css/bootstrap/mixins.less'; @import '../../core/assets/css/bootstrap/grid.less'; @import '../../core/assets/css/bootstrap/layouts.less'; @import '../../core/assets/css/bootstrap/type.less'; @import '../../core/assets/css/bootstrap/forms.less'; @import '../../core/assets/css/bootstrap/tables.less'; @import '../../core/assets/css/bootstrap/sprites.less'; @import 'dropdowns.less'; @import '../../core/assets/css/bootstrap/wells.less'; @import '../../core/assets/css/bootstrap/component-animations.less'; @import '../../core/assets/css/bootstrap/close.less'; @import '../../core/assets/css/bootstrap/buttons.less'; @import '../../core/assets/css/bootstrap/button-groups.less'; @import 'navs.less'; @import 'navbar.less'; @import '../../core/assets/css/bootstrap/breadcrumbs.less'; @import '../../core/assets/css/bootstrap/pagination.less'; @import '../../core/assets/css/bootstrap/pager.less'; @import '../../core/assets/css/bootstrap/popovers.less'; @import '../../core/assets/css/bootstrap/thumbnails.less'; @import '../../core/assets/css/bootstrap/carousel.less'; @import '../../core/assets/css/bootstrap/hero-unit.less'; @import '../../core/assets/css/bootstrap/utilities.less'; @import '../../core/assets/css/bootstrap/responsive-utilities.less'; @import '../../core/assets/css/bootstrap/responsive-767px-max.less'; @import '../../core/assets/css/bootstrap/responsive-768px-979px.less'; @import '../../core/assets/css/bootstrap/responsive-1200px-min.less'; @import 'responsive-navbar.less'; @import 'mixins.less'; @import 'header.less'; @import 'content.less'; @import 'footer.less'; @import 'responsive-overrides.less';
we're getting
expected color value: /home/xxx.com/public_html/wp-content/themes/xxx/assets/css/dstyle.less on line 39
where errors are somewhere within the twitter bootstrap...
is there anyway to turn the color validation off or to have more specific error messaging?
we've also noticed that @{images}sprites.png no longer compiles... is this true?
It would be great to get a line number and file of where the color variable is not set....
Can confirm this issue.
expected color value: failed at `@import "../../bootstrap/less/navs.less";` ~/lib/bootstrap_less/less/bootstrap.less on line 62
The line #62
is the exact line in a file full of @import "file.less";
declarations and the line is the last line in this file. So the error says exactly nothing.
After some investigation I found out that the error comes from ~/lessc/lessc.inc.php#1032
» assertColor()
, where the error message is the default message thrown in by the second (optional) argument.
When I var_dump()
the $value
in this function, I get the following output (actually it's the $value
, so more the input):
array 0 => string 'keyword' (length=7) 1 => string '' (length=0)
What does this tell me? As there're no phpDocBlocks I can only guess - and the arrays are pretty cryptic regarding their content.
The function has a call to coerceColor( $value );
that has a switch
and then triggers for keyword
. But as the arrays 2nd value (the name) stays empty, it returns null
. That's so far what I've traced back.
I don't know where I could step back anymore, as assertColor()
gets called by: lib_hue()
, lib_saturation()
, lib_lightness()
, lib_mix()
- twice - and colorArgs()
. This makes it (as said: without phpDocBlocks) extremely hard to see where the error comes from.
I can confirm this issue is still open for lessc version 0.3.9 and Twitter Bootstrap 2.3.2 as described by @franz-josef-kaiser
same issue here
I can confirm this issue in Twitter Bootstrap 2.3.2
I confirm it for Twitter Bootstrap 3.0.0 I'm getting
expected color value: failed at `color: lighten(@text-color, 25%);
with:
color: lighten(@text-color, 25%);
@Subv, I have same error
Same error here.
I've also hit this issue in a number of WordPress themes attempting to save and compile invalid colors, so I patched this method to skip over throwing an error and revert back to returning rgb(0,0,0)
:
protected function assertColor($value, $error = "expected color value") {
$color = $this->coerceColor($value);
// if (is_null($color)) $this->throwError($error);
// NOTE: Dirty hack to fix issues where the theme would try to compile invalid colors
if (is_null($color)) $color = array('color', 0, 0, 0);
return $color;
}
Maybe that will save somebody else from the frustration of the useless stack trace.