[BUGFIX] Make sure the while loop is not closed

When filterRecordsByRootLineBlacklist() returns no results, loop should just ask
the next items based on iteration
This commit is contained in:
Benjamin Serfhos 2018-10-29 13:49:38 +01:00
parent f1eb85de64
commit 9b0b0305a7
2 changed files with 13 additions and 5 deletions

View file

@ -122,8 +122,10 @@ abstract class AbstractIndexer implements IndexerInterface
$offset = 0; $offset = 0;
$limit = $this->getLimit(); $limit = $this->getLimit();
while (($records = $this->getRecords($offset, $limit)) !== []) { while (($records = $this->getRecords($offset, $limit)) !== null) {
if (!empty($records)) {
yield $records; yield $records;
}
$offset += $limit; $offset += $limit;
} }
} }
@ -194,7 +196,10 @@ abstract class AbstractIndexer implements IndexerInterface
return $this->identifier; return $this->identifier;
} }
abstract protected function getRecords(int $offset, int $limit): array; /**
* @return array|null Nullable when no items are found and execution should be stopped
*/
abstract protected function getRecords(int $offset, int $limit);
/** /**
* @throws NoRecordFoundException If record could not be found. * @throws NoRecordFoundException If record could not be found.

View file

@ -49,11 +49,14 @@ class TcaIndexer extends AbstractIndexer
$this->tcaTableService = $tcaTableService; $this->tcaTableService = $tcaTableService;
} }
protected function getRecords(int $offset, int $limit): array /**
* @return array|null Nullable when no items are found and execution should be stopped
*/
protected function getRecords(int $offset, int $limit)
{ {
$records = $this->tcaTableService->getRecords($offset, $limit); $records = $this->tcaTableService->getRecords($offset, $limit);
if ($records === []) { if ($records === []) {
return []; return null;
} }
$this->tcaTableService->filterRecordsByRootLineBlacklist($records); $this->tcaTableService->filterRecordsByRootLineBlacklist($records);