From: jaco at welnet dot nl
Operating system: CentOS 4.3
PHP version: 5.1.4
PHP Bug Type: SPL related
Bug description: Crash when an exception is thrown in accept() method of
FilterIterator
Description:
------------
Filtering an object which implements Iterator produces the error below,
but an ArrayIterator works fine.
Reproduce code:
---------------
<?
class Collection implements Iterator {
protected $array, $valid = false;
public function __construct(array $a) { $this->array = $a; }
public function current() { return current($this->array); }
public function key() { return key($this->array); }
public function next() { $this->valid = (false !== next($this->array));
}
public function valid() { return $this->valid; }
public function rewind() { $this->valid = (false !==
reset($this->array)); }
}
class TestFilter extends FilterIterator {
public function accept() { throw new Exception("Me crash!"); }
}
$test = new TestFilter( new Collection(array(0)) );
foreach ($test as $item) {
echo $item;
}
?>
Expected result:
----------------
Uncaught exception message.
Actual result:
--------------
>From CLI:
Fatal error: Couldn't execute method Collection::next in Unknown on line
0.
As a httpd module it only prints garbage characters on screen.
--
Edit bug report at http://bugs.php.net/?id=37457&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=37457&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=37457&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=37457&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37457&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=37457&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37457&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37457&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37457&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37457&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37457&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=37457&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=37457&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37457&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37457&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37457&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37457&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37457&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37457&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37457&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37457&r=mysqlcfg