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

Fixed Casting Issue with PHP 7

Affected version
1.5.15a

silence

Well-known member
#1
In the class at library/XenForo/DataWriter/Option.php, at line 327 this seems to prevent installing add-ons with numeric options:

Code:
            case 'numeric': $optionValue = strval($optionValue) + 0; break;
 

Mike

XenForo developer
Staff member
#2
This is fixed for the next release, thanks. You can fix this by replacing this line with:
Code:
case 'numeric': $optionValue = strval(floatval($optionValue)) + 0; break;
However, an easier fix is likely to be to make reasonable assurances that any numeric option you create has a reasonable numeric value. I'm going to take a guess that the default option for this is a blank string (rather than 0).

(Alternatively, it could be someone entering a non-numeric string in which case the line will prevent the error, but equally, it might not be outputting what they expect, such as if they enter a "," for a decimal separator.)

(Note that there is another instance like this in the same file. The fix is similar though not identical.)