https://www.icyphoenix.com/viewtopic.php?f=35&t=8464
-----------------------------------
jhl
Wed 04 Apr, 2012 00:45

The Numeric Value Zero Is Empty()
-----------------------------------
Came across this 'bug' in the version 2.0 beta, file adm/xs_style.php, line 37:

Was:
[code linenumbers=false]
// change "override" variable
$setoverride = request_var('setoverride', 0);
if(!empty($setoverride) && !defined('DEMO_MODE'))
[/code]
The new value is written to the DB in the if statement - which will only fire if !empty(), but 0 *is* empty().

Is now:
[strike][code linenumbers=false]// change "override" variable
$setoverride = request_var('setoverride', $config['override_user_style']);
if(!defined('DEMO_MODE'))
[/code]
[/strike]

Brainfart, sorry - you can just test for a difference:
[code linenumbers=false]$setoverride = request_var('setoverride', $config['override_user_style']);
if(($setoverride != $config['override_user_style']) && !defined('DEMO_MODE'))
[/code]

Since the parameter setoverride *can* legally be zero, the problem is that the code will *never* switch the flag off, but will switch the flag on, with the result (in this case) that user selected styles are premanently overridden.

[strike]I don't know what a correct fix for this would be. I remember seeing a function to check if the parameter is there, but can't remember where or what it is - that would probably be a better solution.

As it is I'm causing a database write hit every time the page is executed[/strike] - but at least it works...

John


