Mantis - Quercus
Viewing Issue Advanced Details
3239 major always 01-12-09 12:10 01-15-09 17:00
haplo  
ferg  
normal  
closed 3.2.1  
fixed  
none    
none 4.0.0  
0003239: Using custom ArrayIterator leeds to a StackOverflowError
This throws an StackOverflow :

class Iteratable implements IteratorAggregate {

    private $data = array();

    public function __construct(){
        $this->data['key1'] = 'value1';
        $this->data['key2'] = 'value2';
        $this->data['key3'] = 'value3';
        $this->data['key4'] = 'value4';
        $this->data['key5'] = 'value5';
    }

    public function getData(){
        return $this->data;
    }
    
    public function getIterator(){
        return new MyIterator($this);
    }
}

class MyIterator extends ArrayIterator{

    private $iteratable;

    public function __construct(Iteratable $iteratable){
        $this->iteratable = $iteratable;
        parent::__construct($iteratable->getData());
    }
}

$iteratable = new Iteratable();
foreach($iteratable as $key => $value){
    echo "$key => $value
\n";
}


Result on Apache:
key1 => value1
key2 => value2
key3 => value3
key4 => value4
key5 => value5

Quercus throws StackOverflowException

Greetings,
Peter

Notes
(0003741)
ferg   
01-15-09 17:00   
php/4as5