From:             yuri dot kanivetsky at gmail dot com
Operating system: linux, windows
PHP version:      5.4.17
Package:          *General Issues
Bug Type:         Bug
Bug description:set_exception_handler and requiring non-existent file

Description:
------------
My code converts errors to exceptions, but it turned out that when faced
with 
"Failed opening required 'whatever'" error, exception handler doesn't get
called. 
More precisely, it doesn't work for require, but works for include.

I tested it on debian 6.0.6 (php-5.4.15), on arch linux (php-5.4.17) and on

windows 7 (php-5.4.17).

Test script:
---------------
#!/usr/bin/env php
<?php

set_error_handler(function() {
    echo "error\n";
    throw new Exception;
});
set_exception_handler(function() {
    echo "exception\n";
});
require 'asdf';


Expected result:
----------------
error
exception


Actual result:
--------------
error
PHP Warning:  Uncaught exception 'Exception' in /home/yuri/1.php:6
Stack trace:
#0 /home/yuri/1.php(11): {closure}(2, 'require(asdf): ...',
'/home/yuri/1.ph...', 
11, Array)
#1 /home/yuri/1.php(11): require()
#2 {main}
  thrown in /home/yuri/1.php on line 6
PHP Fatal error:  main(): Failed opening required 'asdf' 
(include_path='.:/usr/share/php:/usr/share/pear') in /home/yuri/1.php on
line 11

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

Reply via email to