Edit report at https://bugs.php.net/bug.php?id=60909&edit=1
ID: 60909 Updated by: jpa...@php.net Reported by: tyr...@php.net Summary: custom error handler throwing Exception + fatal error = no shutdown function Status: Open Type: Bug Package: Scripting Engine problem Operating System: linux PHP Version: 5.4.0RC6 Block user comment: N Private report: N New Comment: Ok I can reproduce. Try replacing your require (which generates E_COMPILE_ERROR) by an unknown function call (which generates E_ERROR), and all's just fine So there is a trick in the error engine, any kind of fatal shouldn't be handled by user defined error handlers, here we got proof it's not the case Tip: Reproduced on 5.3.10 as well Previous Comments: ------------------------------------------------------------------------ [2012-01-27 18:07:20] tyr...@php.net Description: ------------ first of all sorry for the weird Summary, I couldn't come up with a better one. it is weird. so it seems that if you have a shutdown function callback set and a custom error handler which would throw and exception and you happen to have a fatal error, the shutdown function won't be called. See the attached script, the error handler shouldn't really do anything here, because it won't be called for the fatals, but somehow it still screw things up. If I remove the error handler, I will see the "!!!shutdown!!!" printed. If I put a "return false;" before the throw I will see the "!!!shutdown!!!" printed. If I add E_NOTICE as the $error_type to the set_error_handler call I will see the "!!!shutdown!!!" printed. If I add E_WARNING as the $error_type to the set_error_handler call I will NOT see the "!!!shutdown!!!" printed. wtf? Test script: --------------- <?php register_shutdown_function(function(){echo("\n\n!!!shutdown!!!\n\n");}); set_error_handler(function($errno, $errstr, $errfile, $errline){throw new Exception("Foo");}); require 'notfound.php'; ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60909&edit=1