From:             bschussek at gmail dot com
Operating system: Linux Ubuntu 9.04
PHP version:      5.2.10
PHP Bug Type:     Scripting Engine problem
Bug description:  register_shutdown_function() buggy in combination with 
set_error_handler()

Description:
------------
I registered both a custom error handler and a custom shutdown function.
When calling require with an invalid filename, the following happens:

1. The "warning" error triggers the handler
2. The "fatal" error fires
3. The shutdown function is called

BUT when the error handler throws an exception, no shutdown function is
called. This DOES work when using trigger_error() instead of throwing the
exception.

Reproduce code:
---------------
function error_handler()
{
  var_dump('ERROR');
  throw new Exception('my exception');
}
set_error_handler('error_handler');

function shutdown()
{
  var_dump('SHUTDOWN');
}
register_shutdown_function('shutdown');

require 'foobar.php';

Expected result:
----------------
string(5) "ERROR"

Fatal error: Uncaught exception 'Exception' with message 'my exception'

string(8) "SHUTDOWN"

Actual result:
--------------
string(5) "ERROR"

Fatal error: main(): Failed opening required 'foobar.php'



-- 
Edit bug report at http://bugs.php.net/?id=48969&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=48969&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=48969&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=48969&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=48969&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=48969&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48969&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48969&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48969&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48969&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48969&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48969&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48969&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48969&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48969&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48969&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48969&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48969&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48969&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48969&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48969&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48969&r=mysqlcfg

Reply via email to