Bug #67167 [Csd]: Wrong return value from FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE
| From: | cmb@php.net | Date: | Mon, 18 Mar 2019 10:19:35 +0000 |
| Subject: | Bug #67167 [Csd]: Wrong return value from FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220032@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67167&edit=1
ID: 67167
Updated by: cmb@php.net
Reported by: peter dot schultz at classmarkets dot com
Summary: Wrong return value from FILTER_VALIDATE_BOOLEAN,
FILTER_NULL_ON_FAILURE
Status: Closed
Type: Bug
Package: Filter related
Operating System: Fedora 20
PHP Version: 5.5.12
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
> is false, when it should be null according to the docs
No. The filter_var() docs[1] state:
| Note that scalar values are converted to string internally
| before they are filtered.
So basically you're calling:
filter_var('', FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)
However, FILTER_VALIDATE_BOOLEAN is documented[2] to:
| If FILTER_NULL_ON_FAILURE is set, FALSE is returned only for
| "0", "false", "off", "no", and "" [â¦]
So the behavior complies to the documentation.
[1] <http://php.net/manual/en/function.filter-var.php>
[2] <http://de2.php.net/manual/en/filter.filters.validate.php>
Previous Comments:
------------------------------------------------------------------------
[2019-03-18 09:59:33] lebadap at gmail dot com
Hi guys,
Either this problem persist or i am doing something wrong here.I have PHP version 7.3.1 and the
output of this:
filter_var(null, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)
is false, when it should be null according to the docs
Any ideas?
------------------------------------------------------------------------
[2016-10-17 10:08:29] bwoebi@php.net
Automatic comment on behalf of levim
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cb91a51b0052d512c0110ec934a23e263258e461
Log: Partially fix bug #67167 - Wrong return value...
------------------------------------------------------------------------
[2016-09-09 10:58:53] cmb@php.net
Automatic comment on behalf of levim
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cb91a51b0052d512c0110ec934a23e263258e461
Log: Partially fix bug #67167 - Wrong return value...
------------------------------------------------------------------------
[2016-09-09 10:26:55] cmb@php.net
> Has this bugfix actually landed? If so, in which version, can't
> find it in the changelog.
The fix has only be applied to PHP 7.0.0+, and indeed, it's
missing in the changelog. I'm going to backport to PHP 5.6.
------------------------------------------------------------------------
[2016-09-09 10:23:17] cmb@php.net
Related To: Bug #73054
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=67167
--
Edit this bug report at https://bugs.php.net/bug.php?id=67167&edit=1