mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Don't try to call count() on an iterator
This commit is contained in:
parent
81beddc161
commit
bf331072df
@ -1357,14 +1357,15 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
|
||||
$currentChunk = 0;
|
||||
|
||||
// Keep looping until we run out of chunks
|
||||
while ($chunk = $this->limit($chunkSize, $chunkSize * $currentChunk)->getIterator()) {
|
||||
while ($chunk = $this->limit($chunkSize, $chunkSize * $currentChunk)) {
|
||||
// Loop over all the item in our chunk
|
||||
$count = 0;
|
||||
foreach ($chunk as $item) {
|
||||
$count++;
|
||||
yield $item;
|
||||
}
|
||||
|
||||
|
||||
if ($chunk->count() < $chunkSize) {
|
||||
if ($count < $chunkSize) {
|
||||
// If our last chunk had less item than our chunkSize, we've reach the end.
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user