From:
Operating system: Windows 7 x64
PHP version: 5.3.8
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Exception handler and shutdown hanlder were not called after
throwing exception
Description:
------------
The neither exception handler nor fatal error handler have not been called
if error handler throws exception in case of including not existent file
using require_once.
My PHP version is: PHP Version 5.3.8-ZS5.5.0
Test script:
---------------
<?php
namespace Foo;
class MyErrorHandler {
function __construct() {
set_error_handler(array($this, 'errorHandler'));
set_exception_handler(array($this, 'exceptionHandler'));
register_shutdown_function(array($this, 'fatalErrorHandler'));
}
function errorHandler() {
echo __METHOD__ . "\n";
throw new \Exception('test');
}
function exceptionHandler() {
echo __METHOD__ . "\n"; // should be called!
}
function fatalErrorHandler() {
echo __METHOD__ . "\n"; // should be called!
}
}
echo '<pre>';
$foo = new MyErrorHandler();
require_once __DIR__ . '/not_existing_file.php'; // file should not exist
die();
Expected result:
----------------
Foo\MyErrorHandler::errorHandler
Foo\MyErrorHandler::exceptionHandler
Foo\MyErrorHandler::fatalErrorHandler
Fatal error: main() [function.require]: Failed opening required
'X:\home\localhost\www/not_existing_file.php'
(include_path='D:\system\home\projects\myak\www\includes') in
X:\home\localhost\www\test.php on line 28
Actual result:
--------------
Foo\MyErrorHandler::errorHandler
Fatal error: main() [function.require]: Failed opening required
'X:\home\localhost\www/not_existing_file.php'
(include_path='D:\system\home\projects\myak\www\includes') in
X:\home\localhost\www\test.php on line 28
--
Edit bug report at https://bugs.php.net/bug.php?id=60188&edit=1
--
Try a snapshot (PHP 5.4):
https://bugs.php.net/fix.php?id=60188&r=trysnapshot54
Try a snapshot (PHP 5.3):
https://bugs.php.net/fix.php?id=60188&r=trysnapshot53
Try a snapshot (trunk):
https://bugs.php.net/fix.php?id=60188&r=trysnapshottrunk
Fixed in SVN:
https://bugs.php.net/fix.php?id=60188&r=fixed
Fixed in SVN and need be documented:
https://bugs.php.net/fix.php?id=60188&r=needdocs
Fixed in release:
https://bugs.php.net/fix.php?id=60188&r=alreadyfixed
Need backtrace:
https://bugs.php.net/fix.php?id=60188&r=needtrace
Need Reproduce Script:
https://bugs.php.net/fix.php?id=60188&r=needscript
Try newer version:
https://bugs.php.net/fix.php?id=60188&r=oldversion
Not developer issue:
https://bugs.php.net/fix.php?id=60188&r=support
Expected behavior:
https://bugs.php.net/fix.php?id=60188&r=notwrong
Not enough info:
https://bugs.php.net/fix.php?id=60188&r=notenoughinfo
Submitted twice:
https://bugs.php.net/fix.php?id=60188&r=submittedtwice
register_globals:
https://bugs.php.net/fix.php?id=60188&r=globals
PHP 4 support discontinued:
https://bugs.php.net/fix.php?id=60188&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60188&r=dst
IIS Stability:
https://bugs.php.net/fix.php?id=60188&r=isapi
Install GNU Sed:
https://bugs.php.net/fix.php?id=60188&r=gnused
Floating point limitations:
https://bugs.php.net/fix.php?id=60188&r=float
No Zend Extensions:
https://bugs.php.net/fix.php?id=60188&r=nozend
MySQL Configuration Error:
https://bugs.php.net/fix.php?id=60188&r=mysqlcfg