• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Not a bug CSS Error (due to php notice); A non-numeric value encountered (php7.1)

Xon

Well-known member
#1
I've noticed that numerically computed CSS attributes based off style-properties can print the "non-numeric value" notice. So far this has only occurred on my dev environment on a custom theme when throwing an error on a particular page.

But it looks like this could occur on the standard theme

Default values for style properties:
headerLogoHeight:50px
headerTabHeight:25px

From /internal_data/templates/S.1,L.0,public.css.php
Code:
                line-height: ' . (XenForo_Template_Helper_Core::styleProperty('headerLogoHeight') - 4) . 'px;
                *line-height: ' . XenForo_Template_Helper_Core::styleProperty('headerLogoHeight') . ';
These output:
Code:
PHP Notice:  A non well formed numeric value encountered in /internal_data/templates/S.1,L.0,public.css.php on line 16
...
                line-height: 46px;
                *line-height: 50px
headerLogoHeight/headerTabHeight are documented as being in pixels, but a bunch of the css assumes it has units while the other assumes it doesn't have units.
 

Arty

Well-known member
#2
You need to wrap all numeric values in calculations that might have units or might be empty in intval:
Code:
line-height: {xen:calc 'intval(@headerLogoHeight) - 4'}px;
It was changed in default style in 1.5.8 or 1.5.9. Your code is outdated.
 

Xon

Well-known member
#3
You need to wrap all numeric values in calculations that might have units or might be empty in intval:
Code:
line-height: {xen:calc 'intval(@headerLogoHeight) - 4'}px;
It was changed in default style in 1.5.8 or 1.5.9. Your code is outdated.
Yup, missed an update. Not sure how I missed that