From:
Operating system: All
PHP version: 5.3.2
Package: Scripting Engine problem
Bug Type: Bug
Bug description:set_error_handler() misbehave under certain circumstancies
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 bug report at http://bugs.php.net/bug.php?id=51487&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51487&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51487&r=trysnapshot53
Try a snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=51487&r=trysnapshot60
Fixed in SVN:
http://bugs.php.net/fix.php?id=51487&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=51487&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51487&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=51487&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=51487&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=51487&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=51487&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=51487&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=51487&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=51487&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51487&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51487&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51487&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=51487&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=51487&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=51487&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=51487&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=51487&r=mysqlcfg