#37416 [NEW]: Exception in rewind() method crashes iterator_to_array() function

From: Date: Fri, 12 May 2006 08:07:50 +0000
Subject: #37416 [NEW]: Exception in rewind() method crashes iterator_to_array() function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97004@lists.php.net to get a copy of this message
From:             suhachov at gmail dot com
Operating system: WinXP
PHP version:      5.1.4
PHP Bug Type:     SPL related
Bug description:  Exception in rewind() method crashes iterator_to_array() function

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 bug report at http://bugs.php.net/?id=37416&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37416&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37416&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37416&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37416&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=37416&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37416&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37416&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37416&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37416&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37416&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=37416&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=37416&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37416&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37416&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37416&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37416&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37416&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37416&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37416&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37416&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#97004) next »