Bug #67167 [Asn->Csd]: Wrong return value from FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE

From: Date: Thu, 03 Sep 2015 00:27:10 +0000
Subject: Bug #67167 [Asn->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-195722@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: levim@php.net Reported by: peter dot schultz at classmarkets dot com Summary: Wrong return value from FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE -Status: Assigned +Status: Closed Type: Bug Package: Filter related Operating System: Fedora 20 PHP Version: 5.5.12 Assigned To: levim Block user comment: N Private report: N New Comment: Automatic comment on behalf of levim Revision: http://git.php.net/?p=php-src.git;a=commit;h=432dc527adcbc3bf4809f6315350300d42c16c52 Log: Partially fix bug #67167 - Wrong return value... Previous Comments: ------------------------------------------------------------------------ [2015-09-02 13:48:45] cmb@php.net > It appears that pajoye is correct; there is a convert_to_string > call that messes all of this up. I wonder why the first argument of filter_var() isn't string instead of mixed. ------------------------------------------------------------------------ [2014-05-08 07:32:14] pajoye@php.net > It appears that pajoye is correct; there is a convert_to_string call that messes > all of > this up. One solution, not very nice and hackish, is to add a test along: if not (filter==boolean && type in (integer, boolean)) convert to string then call the filter ------------------------------------------------------------------------ [2014-05-08 06:04:54] infinitythe7th at gmx dot net Not 100% sure about it, but that sounds as close to the documentation we have as I can see. ------------------------------------------------------------------------ [2014-05-08 05:56:20] levim@php.net I think FILTER_VALIDATE_BOOLEAN with FILTER_NULL_ON_FAILURE should return null for an array, an object that doesn't have __toString(), null, and a resource. For objects with __toString it depends on the result of the cast; the same goes for floats and integers. Sound good? ------------------------------------------------------------------------ [2014-05-08 05:22:33] levim@php.net Here's the exact quote: > If FILTER_NULL_ON_FAILURE is set, FALSE is returned only for "0", "false", > "off", "no", and "", and NULL is returned for all non-boolean values. It seems I misread; that does sound like it should return null for anything that fails is_bool. ------------------------------------------------------------------------ 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

« previous php.bugs (#195722) next »