- Affected version
- 2.3.10
I'm running XenForo 2.3.10 and I've run into a strange issue with style variations.
I would prefer to disable style variations on my custom style, but doing so causes large portions of the site's CSS to fail to compile and essentially destroys the layout.
With "Enable variations" checked, everything works normally.
If I uncheck it and save the style, I immediately start getting errors like:
Error rendering template:
Example CSS:
Other examples that fail include:
The exception ultimately ends up here:
src/vendor/oyejorge/less.php/lib/Less/Functions.php
The stack trace shows Less_Tree_Call dispatching the CSS clamp() call to Less_Functions::clamp(), with Less_Tree_Dimension objects as the arguments.
What makes this interesting is that it only happens when style variations are disabled.
Looking through XF's CSS renderer, it appears that when the style is using the variation-variable path, HslColorPreEvalVisitor/HslColorPreVisitor are installed. HslColorPreEvalVisitor specifically recognizes a call named "clamp" and converts it to XF's HslClamp representation, which ultimately outputs the CSS clamp() function normally.
When variations are disabled, that visitor path appears not to be active, and the raw CSS clamp() call instead gets picked up by Less_Functions::clamp().
Re-enabling variations immediately restores the site.
I also ran XenForo's File Health Check. The relevant files involved in this path, including CssRenderer.php, Less/Functions.php and Less/Tree/Call.php, are not reported as modified.
I found an older report with a very similar Less_Tree_Dimension/clamp error that was apparently fixed around 2.3.6, but I'm seeing this reproducibly on 2.3.10.
Has anyone else encountered this on 2.3.10?
More importantly, is there a supported/clean way to fix it so style variations can actually be disabled?
I'd prefer not to:
For now I've had to leave "Enable variations" turned on because disabling it makes the site unusable.
Any insight from XenForo staff or anyone familiar with the LESS/variation rendering path would be greatly appreciated.
I would prefer to disable style variations on my custom style, but doing so causes large portions of the site's CSS to fail to compile and essentially destroys the layout.
With "Enable variations" checked, everything works normally.
If I uncheck it and save the style, I immediately start getting errors like:
Error rendering template:
public:custom_layout.lesserror evaluating function `clamp`[E_NOTICE] Object of class Less_Tree_Dimension could not be converted to intExample CSS:
gap: clamp(2rem, 5vw, 5rem);Other examples that fail include:
--custom-layout-width: clamp(12rem, 12.5vw, 14.5rem);--custom-layout-gap: clamp(1.25rem, 1.6vw, 2rem);gap: clamp(16px, 1.7vw, 24px);padding: clamp(1.35rem, 3vw, 2.45rem);The exception ultimately ends up here:
src/vendor/oyejorge/less.php/lib/Less/Functions.php
public static function clamp($val, $max = 1){ return min(max($val, 0), $max);}The stack trace shows Less_Tree_Call dispatching the CSS clamp() call to Less_Functions::clamp(), with Less_Tree_Dimension objects as the arguments.
What makes this interesting is that it only happens when style variations are disabled.
Looking through XF's CSS renderer, it appears that when the style is using the variation-variable path, HslColorPreEvalVisitor/HslColorPreVisitor are installed. HslColorPreEvalVisitor specifically recognizes a call named "clamp" and converts it to XF's HslClamp representation, which ultimately outputs the CSS clamp() function normally.
When variations are disabled, that visitor path appears not to be active, and the raw CSS clamp() call instead gets picked up by Less_Functions::clamp().
Re-enabling variations immediately restores the site.
I also ran XenForo's File Health Check. The relevant files involved in this path, including CssRenderer.php, Less/Functions.php and Less/Tree/Call.php, are not reported as modified.
I found an older report with a very similar Less_Tree_Dimension/clamp error that was apparently fixed around 2.3.6, but I'm seeing this reproducibly on 2.3.10.
Has anyone else encountered this on 2.3.10?
More importantly, is there a supported/clean way to fix it so style variations can actually be disabled?
I'd prefer not to:
- modify XenForo core/vendor files, or
- rewrite otherwise-valid CSS clamp() usage throughout the custom style just to work around the LESS parser.
For now I've had to leave "Enable variations" turned on because disabling it makes the site unusable.
Any insight from XenForo staff or anyone familiar with the LESS/variation rendering path would be greatly appreciated.