mirror of
https://github.com/predis/predis.git
synced 2026-09-11 19:07:30 +00:00
use a loop instead of recursion in CursorBasedIterator
servers with large sets of keys will cause memory and stack exhaustion if recursion is used
This commit is contained in:
@@ -165,17 +165,21 @@ abstract class CursorBasedIterator implements Iterator
|
||||
*/
|
||||
public function next()
|
||||
{
|
||||
if (!$this->elements && $this->fetchmore) {
|
||||
$this->fetch();
|
||||
}
|
||||
do {
|
||||
$more = false;
|
||||
|
||||
if ($this->elements) {
|
||||
$this->extractNext();
|
||||
} elseif ($this->cursor) {
|
||||
$this->next();
|
||||
} else {
|
||||
$this->valid = false;
|
||||
}
|
||||
if (!$this->elements && $this->fetchmore) {
|
||||
$this->fetch();
|
||||
}
|
||||
|
||||
if ($this->elements) {
|
||||
$this->extractNext();
|
||||
} elseif ($this->cursor) {
|
||||
$more = true;
|
||||
} else {
|
||||
$this->valid = false;
|
||||
}
|
||||
} while ($more);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user