? Failure
Pull Request for # 5851

User tests: Successful: Unsuccessful:

avatar klas
klas
21 Jan 2015

When parameter with empty value is passed to the JInput and filter is INT, JInput will return 0 instead of default value. There is similar problem with other fitlers too as isset will consider "" as set, and afterwards fitlers will perform typecasting on it.

Fixes #5851

avatar klas klas - open - 21 Jan 2015
avatar jissues-bot jissues-bot - change - 21 Jan 2015
Labels Added: ?
avatar brianteeman brianteeman - change - 21 Jan 2015
Category Libraries
avatar brianteeman brianteeman - change - 21 Jan 2015
Rel_Number 5851
Relation Type Pull Request for
avatar rdeutz
rdeutz - comment - 21 Jan 2015

I expect to get an int back when I filter on int, don't see the problem here.

avatar wilsonge
wilsonge - comment - 21 Jan 2015

I agree. I consider this expected behaviour.

avatar brianteeman
brianteeman - comment - 21 Jan 2015

I am closing this as expected behaviour based on the comments by the two PLT members above


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5852.
avatar brianteeman brianteeman - change - 21 Jan 2015
Status Pending Expected Behaviour
Closed_Date 0000-00-00 00:00:00 2015-01-21 19:15:26
Closed_By brianteeman
avatar brianteeman brianteeman - change - 21 Jan 2015
Closed_Date 2015-01-21 19:15:26 2015-01-21 19:15:27
avatar brianteeman brianteeman - close - 21 Jan 2015
avatar klas
klas - comment - 22 Jan 2015

Please consider reopening this:
If 0 is expected behaviour here then function is flawed in different way - when variable is not set in url at all, you don't get 0, you get default value. Variable without value should be treated in the same way as variable that is not present at all.

Underlying problem is php assigning empty string instead of null to the parameters without value http://php.net/manual/en/reserved.variables.get.php#98419


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/5852.
avatar rdeutz
rdeutz - comment - 22 Jan 2015

Your are mixing things:

If it is not set in the url and we follow your thinking, then JInput->get('notsetvar', 'whatever', 'int') will return "whatever". That isn't an int nor nothing, so it couldn't be more wrong.

If you need to check, if something is part of the url you can use the JUri class. The purpose of the JInput class is to protect before injecting something that we will not have gotten via the request.

avatar Bakual
Bakual - comment - 22 Jan 2015

I agree with Robert that JInput->getInt should always return an int. Your default value null is basically an invalid default value for that method and gets correctly converted to 0.

avatar klas
klas - comment - 22 Jan 2015

When variable is not present in the url JInput->get('notsetvar', 'whatever', 'int') will indeed return 'whatever'. Please check by yourself.

But you get different result when url has this variable, just without any value. Hope this makes sense, what I'm talking about is that with the abouve code you get "whatever" when url is index.php?abc=1 and you get 0 when url is index.php?whatever=&abc=1.

I was wrongly trying to change this second behaviour while it seems now it is the first instance that needs fixing.

Add a Comment

Login with GitHub to post a comment