Bug #67167 [ReO->Csd]: Wrong return value from FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE
| From: | cmb@php.net | Date: | Fri, 09 Sep 2016 10:58:54 +0000 |
| Subject: | Bug #67167 [ReO->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-203907@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: Re-Opened
+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:
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...
Previous Comments:
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
[2016-07-20 11:36:45] davey@php.net
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...
------------------------------------------------------------------------
[2016-01-25 09:46:17] b-roeser at gmx dot net
Sorry, when pasting the output from the console, I pasted a little bit too much, hope it is still
clear.
------------------------------------------------------------------------
[2016-01-25 09:43:49] b-roeser at gmx dot net
Hi there,
Has this bugfix actually landed? If so, in which version, can't find it in the changelog.
I'm currently testing on PHP 5.6.11-1ubuntu3.1 and I can still reproduce the problem. Here is
my test case:
<?php
class x {}
class y {
public $m = 'n';
function doStuff() {
$this->m = 'l';
}
}
$value = 'x';
var_dump(filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE));
// expected: NULL â works as expected
$value = new stdClass();
var_dump(filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE));
// expected: NULL â returns false
$value = new x();
var_dump(filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE));
// expected: NULL â returns false
$value = new y();
var_dump(filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE));
// expected: NULL â returns false
var_dump((string)$value);
This is the output I get:
NULL
bool(false)
bool(false)
bool(false)
PHP Catchable fatal error: Object of class y could not be converted to string in
/home/benedict/Repositories/wellid/testcase.php on line 30
PHP Stack trace:
PHP 1. {main}() /home/benedict/Repositories/wellid/testcase.php:0
benedict@minerva:~/Repositories/wellid$ vim testcase.php
benedict@minerva:~/Repositories/wellid$ php -f testcase.php
NULL
bool(false)
bool(false)
bool(false)
PHP Catchable fatal error: Object of class y could not be converted to string in
/home/benedict/Repositories/wellid/testcase.php on line 30
PHP Stack trace:
PHP 1. {main}() /home/benedict/Repositories/wellid/testcase.php:0
As you can see, none of these have a __toString()-method.
Am I missing something?
------------------------------------------------------------------------
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