XenForo_Application::set won't set a 0 value

SpecialK

Well-known member
I'm passing data from my extended admin controller to my extended datawriter using XenForo_Application::set() in the controller and XenForo_Application::get() in the datawriter. The problem I'm running into is that if XenForo_Application::set() is called with a 0 or even a '0' for the value, it doesn't actually get set. IE, XenForo_Application::set('testing', 0); doesn't work. If I call that and then later call
XenForo_Application::isRegistered('testing')), I get a false returned instead of a true. So my questions are:

1. Is there a better way to pass data into the datawriter from an extended controller?
2. Assuming this is the best way, how do I go about sending a 0 to the datawriter?

In case the font makes it unclear, I'm talking about zero here, not O/o/Oh

I know that I could just initialize the datawriter in my extended controller and save my values there instead of trying to set them in the controller and retrieve in the datawriter, but that results in an extra insert. If that's the recommended way of inserting this data, I'll go with it, but I'm hoping there's an easy way to utilize the _preSave() method in the datawriter so that I don't have two inserts.
 
Last edited:
I just tested with this code:

Code:
XenForo_Application::set('test', 0);
var_dump(XenForo_Application::isRegistered('test'));
var_dump(XenForo_Application::get('test'));

And it outputs:

Code:
bool(true)
int(0)

So I think there might be something else at play here.
 
Ah, you're right. I was doing a check in the form of

PHP:
 if($test = $this->_input->filterSingle('test', XenForo_Input::UINT)) {}

So when the submitted value was a 0, that if function was receiving a false. I was too busy trying to figure out why it wasn't setting that I didn't check the logic.

Thanks Mike.
 
Top Bottom