Icy Phoenix

     
 

The Numeric Value Zero Is Empty()

The Numeric Value Zero Is Empty()

Article
Reply with quote    Download Post 
Post 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: [Download] [Hide] [Select]
// change "override" variable
$setoverride = request_var('setoverride', 0);
if(!empty($setoverride) && !defined('DEMO_MODE'))

The new value is written to the DB in the if statement - which will only fire if !empty(), but 0 *is* empty().

Is now:
Code: [Download] [Hide] [Select]
// change "override" variable
$setoverride = request_var('setoverride', $config['override_user_style']);
if(!defined('DEMO_MODE'))



Brainfart, sorry - you can just test for a difference:
Code: [Download] [Hide] [Select]
$setoverride = request_var('setoverride', $config['override_user_style']);
if(($setoverride != $config['override_user_style']) && !defined('DEMO_MODE'))


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.

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
- but at least it works...

John



 
jhl - View user's profile Send private message  
jhl [ Wed 04 Apr, 2012 00:45 ]
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us


The Numeric Value Zero Is Empty()

Comments
Display posts from previous:    

HideWas this topic useful?

Post new topic  Reply to topic  Page 1 of 1