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

Reply via email to