#49274 [Ana->Asn]: filter_var() should accept objects without fatal error
| From: | pajoye@php.net | Date: | Sat, 05 Sep 2009 17:37:04 +0000 |
| Subject: | #49274 [Ana->Asn]: filter_var() should accept objects without fatal error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-142007@lists.php.net to get a copy of this message | ||
ID: 49274
Updated by: pajoye@php.net
Reported By: cellog@php.net
-Status: Analyzed
+Status: Assigned
Bug Type: Feature/Change Request
Operating System: *
PHP Version: 5.3SVN-2009-08-16 (SVN)
-Assigned To:
+Assigned To: pajoye
New Comment:
I will close it as soon as it gets merged in 5.3.1, if the RM agrees.
Previous Comments:
------------------------------------------------------------------------
[2009-09-05 17:35:27] svn@php.net
Automatic comment from SVN on behalf of pajoye
Revision: http://svn.php.net/viewvc/?view=revision&revision=288083
Log: - fix #49274, filter_var does not accept object without a toString
implementation
------------------------------------------------------------------------
[2009-08-17 21:59:13] pajoye@php.net
http://pastie.org/586442 should do it. I did not not test
more than the
test case here.
------------------------------------------------------------------------
[2009-08-17 13:55:58] pajoye@php.net
it is indeed valid for all objects but it is still an edge case.
A check for IS_OBJECT + tostring() existence could be easy enough and
with almost no impact(perf impact is null on the existing application).
If you have some time to write one, go ahead.
------------------------------------------------------------------------
[2009-08-17 13:52:56] cellog@php.net
the stdClass was just to illustrate the point, this happens with any
object that doesn't have a __toString(). I would imagine it would be
easier to check for IS_OBJECT and then see if it implements __toString
than to do a custom error handler. The performance should be about the
same (dismal).
------------------------------------------------------------------------
[2009-08-17 13:48:45] pajoye@php.net
As StdClass has no __toString implementation (obviously), it can't be
converted to string.
I tend to agree that it should not raise a fatal (recovable error) here
as it defeats the main purpose of this API.
I'm however not sure it is worth the effort to add custom error handler
for this edge case. Patch welcome, it could help to get this edge case
solved (I can't work on this exact issue any time soon).
------------------------------------------------------------------------
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
http://bugs.php.net/49274
--
Edit this bug report at http://bugs.php.net/?id=49274&edit=1