#37416 [Opn->Csd]: Exception in rewind() method crashes iterator_to_array() function
ID: 37416
Updated by: tony2001@php.net
Reported By: suhachov at gmail dot com
-Status: Open
+Status: Closed
Bug Type: SPL related
Operating System: WinXP
PHP Version: 5.1.4
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Just for the record: "crash" is something different.
"Fatal error in Unknown" is not a crash.
Previous Comments:
------------------------------------------------------------------------
[2006-05-12 08:07:50] suhachov at gmail dot com
Description:
------------
I call iterator_to_array($iter) and if something bad is happend in
rewind() function and exception is thrown, script dies instead of
throwing the exception.
It looks like bug #32993 but it should be fixed still in PHP 5.0
Reproduce code:
---------------
<?
class MyIterator implements Iterator
{
public function rewind () # void
{
throw new Exception("Oops!");
}
public function valid () # bool
{
return 0;
}
public function current () # object
{
return NULL;
}
public function key () # void
{
return 0;
}
public function next () # void
{
}
}
var_dump(iterator_to_array(new MyIterator));
?>
Expected result:
----------------
Exception stack trace
Actual result:
--------------
Fatal error: Couldn't execute method MyIterator::valid in Unknown on
line 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37416&edit=1
Thread (3 messages)