Edit report at http://bugs.php.net/bug.php?id=51487&edit=1

 ID:               51487
 Updated by:       johan...@php.net
 Reported by:      fabien dot potencier at symfony-project dot org
 Summary:          set_error_handler() misbehave under certain
                   circumstancies
-Status:           Open
+Status:           Feedback
 Type:             Bug
 Package:          Scripting Engine problem
 Operating System: All
 PHP Version:      5.3.2

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[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

Reply via email to