#44295 [Opn->Asn]: DirectoryIterator::__construct() exception + set_error_handler broken

From: Date: Mon, 03 Mar 2008 12:59:13 +0000
Subject: #44295 [Opn->Asn]: DirectoryIterator::__construct() exception + set_error_handler broken
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-122864@lists.php.net to get a copy of this message
ID: 44295 Updated by: jani@php.net Reported By: web-php-bugs at sklar dot com -Status: Open +Status: Assigned Bug Type: SPL related Operating System: OS X 10.4 PHP Version: 5.2.5 Assigned To: colder Previous Comments: ------------------------------------------------------------------------ [2008-02-29 20:52:25] web-php-bugs at sklar dot com 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 this bug report at http://bugs.php.net/?id=44295&edit=1

« previous php.bugs (#122864) next »