XF 2.3 How can I safely disable style variations? Doing so breaks LESS compilation

CrazyChef

Active member
Licensed customer
I'm hoping somebody here can help me find a practical solution to a style-variation problem I'm having on XenForo 2.3.10.

I want to disable style variations on my custom style.

The problem is that if I uncheck "Enable variations" and save the style, large portions of the site's CSS immediately fail to compile and the layout becomes essentially unusable.

With variations enabled, everything works normally.

The errors are caused by ordinary CSS clamp() expressions such as:

gap: clamp(2rem, 5vw, 5rem);

and:

--custom-layout-width: clamp(12rem, 12.5vw, 14.5rem);

When variations are disabled, I start getting errors such as:

error evaluating function clamp
[E_NOTICE] Object of class Less_Tree_Dimension could not be converted to int


The stack trace eventually reaches:

src/vendor/oyejorge/less.php/lib/Less/Functions.php

where clamp() is defined as:

public static function clamp($val, $max = 1)
{
return min(max($val, 0), $max);
}

As soon as I re-enable style variations, the site works normally again.

I've already run XenForo's File Health Check, and the relevant XenForo/LESS files involved in the error are not reported as modified.

I also posted the detailed technical findings in Bug reports, but what I'm really looking for here is a practical solution.

Has anyone encountered this on XF 2.3.10?

Is there a supported way to disable style variations without having valid CSS clamp() expressions get interpreted by the LESS numeric clamp function?

I'd really prefer not to modify XenForo core/vendor files or go through the entire custom style rewriting otherwise-valid CSS just to work around it.

At the moment I'm forced to leave variations enabled even though I don't want members using them.

Any ideas would be appreciated.
 
You can put your clamp rules in a .css template instead of a .less template and they won't be parsed by the Less compiler at all.
 
You can put your clamp rules in a .css template instead of a .less template and they won't be parsed by the Less compiler at all.
Thank you for the reply. That clears things up quite a bit and gives me a much better understanding of how XenForo handles this. I really appreciate you taking the time to explain it.
 
Back
Top Bottom