You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the getQuery() function of the Http\Request object only returns the default value, when the requested parameter is not being used at all.
Examplecode:
<?php$di = newPhalcon\DI\FactoryDefault();
$app = newPhalcon\Mvc\Micro();
$app->setDI($di);
$app->get('/', function () use ($app) {
echo("->".$app['request']->getQuery('id', 'int', 100));
});
$app->handle();
Requests
Example 1
Request: http://localhost/test.php?id=aa
Returned value: ""
Example 2
Request: http://localhost/test.php?id=a11a
Returned value: "11"
Example 3
Request: http://localhost/test.php?id=
Returned value: ""
Example 4
Request: http://localhost/test.php
Returned value: "100"
As in example 4 i would expect to get the default value in the examples 1 and 3 as well, since the given values have been removed by the "int" filter.
A default value is suppose to be returned as soon as there is nothing to return - this is regardless if there is no parameter given, a parameter is empty or the filter emptied the parameter.
The result is always the same - i do not get any value back and i need my default value.
In my case i need to implement additional checks every time i use that funtion, because i can not rely on it to at least return my default value. That will result into additional unnecessary lines of code.
Just to make sure - i understand, that i need to add "false" to get the desired behaviour.
This would be quite nice, even though i would prefer not to do add the parameter, but the backwards compatibility needs to be ensured of course!
Thanks for the nice work - looking forward to the approval :)
Currently the getQuery() function of the Http\Request object only returns the default value, when the requested parameter is not being used at all.
Examplecode:
Requests
Example 4 Request: http://localhost/test.php Returned value: "100"
As in example 4 i would expect to get the default value in the examples 1 and 3 as well, since the given values have been removed by the "int" filter.
A default value is suppose to be returned as soon as there is nothing to return - this is regardless if there is no parameter given, a parameter is empty or the filter emptied the parameter.
The result is always the same - i do not get any value back and i need my default value.
In my case i need to implement additional checks every time i use that funtion, because i can not rely on it to at least return my default value. That will result into additional unnecessary lines of code.
Related forum thread: http://forum.phalconphp.com/discussion/877/error-message-when-using-integer-filter-in-getquery-function-of-
The text was updated successfully, but these errors were encountered: