Backport fix for cursor-based iterator abstraction from PR #182.

This commit is contained in:
Daniele Alessandri
2014-07-07 10:50:17 +02:00
parent 8373663486
commit b77da8476c
@@ -166,16 +166,18 @@ abstract class CursorBasedIterator implements Iterator
*/
public function next()
{
if (!$this->elements && $this->fetchmore) {
$this->fetch();
}
tryFetch: {
if (!$this->elements && $this->fetchmore) {
$this->fetch();
}
if ($this->elements) {
$this->extractNext();
} elseif ($this->cursor) {
$this->next();
} else {
$this->valid = false;
if ($this->elements) {
$this->extractNext();
} elseif ($this->cursor) {
goto tryFetch;
} else {
$this->valid = false;
}
}
}