[php-src] Issue #7894: filter_var("false", FILTER_VALIDATE_BOOL returns the set default value
| From: | damianwadley | Date: | Thu, 06 Jan 2022 10:50:11 +0000 |
| Subject: | [php-src] Issue #7894: filter_var("false", FILTER_VALIDATE_BOOL returns the set default value | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-238795@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/7894
Comment Author: damianwadley
Oh, I didn't notice that either.
Technically this behavior is correct: without FILTER_NULL_ON_FAILURE, the filter only
"allows" truthy values, and since "false" is not truthy it's rejected - and
the default is used. That flag adds an additional behavior to give special handling to falsey
values, so no flag means no special handling.
It might be a bit surprising, but (a) it's documented like this, (b) there is a
"workaround" of providing FILTER_NULL_ON_FAILURE, and (c) changing this could break
compatibility.