Edit report at http://bugs.php.net/bug.php?id=51487&edit=1
ID: 51487
Comment by: fabien dot potencier at symfony-project dot org
Reported by: fabien dot potencier at symfony-project dot org
Summary: set_error_handler() misbehave under certain
circumstancies
Status: Feedback
Type: Bug
Package: Scripting Engine problem
Operating System: All
PHP Version: 5.3.2
New Comment:
I have just tested with php5.3-201004061030, and the problem is not
fixed.
The output is indeed better, as the line is not 0 anymore:
Call to a member function call() on a non-object in ... on line 9
instead of:
Call to a member function call() on a non-object in ... on line 0
Previous Comments:
------------------------------------------------------------------------
[2010-04-06 14:31:45] [email protected]
bug #51463 might be related, stas also worked on a similar bug where I
don't find the commit or bug id right now. Could you pleasetest the
latest snapshot, maybe this was fixed. Thanks.
------------------------------------------------------------------------
[2010-04-06 13:56:59] fabien dot potencier at symfony-project dot org
Description:
------------
When throwing an exception from a custom error handler, PHP sometimes
dies with a non-obvious error as the actual problem is hidden.
To reproduce, create a simple set_error_handler() and throw an exception
(ErrorException here) whenever an error occur (with error_reporting set
to -1 for instance).
If you try to output a not-defined variable, you will see the Exception.
But, if you call a method on a not-defined variable, the exception is
not thrown, and an error message is displayed instead. Debugging is not
trivial as the real problem is masked.
Test script:
---------------
set_error_handler(function ($level, $message, $file, $line, $context)
{
throw new \ErrorException($message);
});
// will throw an Exception (Undefined variable: foo)
// echo $foo;
// will not throw the exception, PHP will try to call bar() instead
$foo->bar();
Expected result:
----------------
PHP Fatal error: Uncaught exception 'ErrorException' with message
'Undefined variable: foo' in ..:..
Actual result:
--------------
PHP Fatal error: Call to a member function bar() on a non-object in ...
on line 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51487&edit=1