diff options
author | Steve Clay <steve@mrclay.org> | 2013-06-04 22:50:58 -0400 |
---|---|---|
committer | Steve Clay <steve@mrclay.org> | 2013-06-04 22:50:58 -0400 |
commit | 708d2fcdc07986ee8bce5838f03f1375e8cd6d5e (patch) | |
tree | 9f25de5f5edb86f95e259af9402177e738619b53 /engine/classes/ElggBatch.php | |
parent | 35acc4a297de7660a191d4e7f9d3e8d55561885a (diff) | |
download | elgg-708d2fcdc07986ee8bce5838f03f1375e8cd6d5e.tar.gz elgg-708d2fcdc07986ee8bce5838f03f1375e8cd6d5e.tar.bz2 |
Fixes #5357: ElggBatch can now skip incomplete entities
Diffstat (limited to 'engine/classes/ElggBatch.php')
-rw-r--r-- | engine/classes/ElggBatch.php | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/engine/classes/ElggBatch.php b/engine/classes/ElggBatch.php index 34520f2bc..83963ccee 100644 --- a/engine/classes/ElggBatch.php +++ b/engine/classes/ElggBatch.php @@ -291,14 +291,19 @@ class ElggBatch $this->incompleteEntities = array(); $this->results = call_user_func_array($this->getter, array($options)); - if ($this->incompleteEntities) { - // @todo what to do here? - } - if ($this->results) { + // If there were incomplete entities, we pretend they were at the beginning of the results, + // fool the local counter to think it's skipped by them already, and update the running + // total as if the results contained the incompletes. + if ($this->results || $this->incompleteEntities) { $this->chunkIndex++; - $this->resultIndex = 0; - $this->retrievedResults += count($this->results); + $this->resultIndex = count($this->incompleteEntities); + $this->retrievedResults += (count($this->results) + count($this->incompleteEntities)); + if (!$this->results) { + // This fetch was *all* incompletes! We need to fetch until we can either + // offer at least one row to iterate over, or give up. + return $this->getNextResultsChunk(); + } return true; } else { return false; |