From: web-php-bugs at sklar dot com
Operating system: OS X 10.4
PHP version: 5.2.5
PHP Bug Type: SPL related
Bug description: DirectoryIterator::__construct() exception +
set_error_handler broken
Description:
------------
When set_error_handler() has been used to set a custom error handler, the
RuntimeException thrown by DirectoryIterator::__construct() is not handled
properly -- the user error handler runs and then code continues after the
constructor instead of the exception being thrown.
This is specific to DirectoryIterator, if you replace "$iter = new
DirectoryIterator($dir)" with just "throw new Exception('monkey');" in the
reproduce code below, the catch block executes OK.
Reproduce code:
---------------
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors',true);
$dir = '/this/path/does/not/exist';
set_error_handler('my_error_handler');
function my_error_handler() { print "in error handler\n"; }
try {
print "before\n";
$iter = new DirectoryIterator($dir);
print get_class($iter) . "\n";
print "after\n";
} catch (Exception $e) {
print "in catch\n";
}
Expected result:
----------------
before
in catch
Actual result:
--------------
before
in error handler
DirectoryIterator
after
--
Edit bug report at http://bugs.php.net/?id=44295&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=44295&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=44295&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=44295&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=44295&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=44295&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=44295&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=44295&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=44295&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=44295&r=support
Expected behavior: http://bugs.php.net/fix.php?id=44295&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=44295&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=44295&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=44295&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=44295&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=44295&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=44295&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=44295&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=44295&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=44295&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=44295&r=mysqlcfg