From:             vojtech at x dot cz
Operating system: gnu/linux
PHP version:      5.0.4
PHP Bug Type:     Zend Engine 2 problem
Bug description:  implemented Iterator function curreent() don't throw exception

Description:
------------
It's seems there is not correctly processed exception from current() and
script ends up with fatal error.

Reproduce code:
---------------
class Test implements Iterator {

    public $arr = array();

    public function rewind()    { return reset($this->arr); }
    public function current()   { throw new Exception(); }
    public function key()       { return key($this->arr); }
    public function next()      { return next($this->arr); }
    public function valid()     { return (current($this->arr) !== false);
}
}

$t = new Test();
$t->arr =  array(1, 2, 3);

try {
    foreach ($t as $v) {
        ; // do something
    }
} catch (Exception $e) {
    ; // handle exception
}


Actual result:
--------------
Fatal error: Couldn't execute method Test::key in Unknown on line 0

-- 
Edit bug report at http://bugs.php.net/?id=32993&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32993&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32993&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32993&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32993&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32993&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32993&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32993&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32993&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32993&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32993&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32993&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32993&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32993&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32993&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32993&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32993&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32993&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32993&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32993&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32993&r=mysqlcfg

Reply via email to