From 9b0b0305a7a8b957efb656bc79c4c93fc57e0068 Mon Sep 17 00:00:00 2001 From: Benjamin Serfhos Date: Mon, 29 Oct 2018 13:49:38 +0100 Subject: [PATCH] [BUGFIX] Make sure the while loop is not closed When filterRecordsByRootLineBlacklist() returns no results, loop should just ask the next items based on iteration --- Classes/Domain/Index/AbstractIndexer.php | 11 ++++++++--- Classes/Domain/Index/TcaIndexer.php | 7 +++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Classes/Domain/Index/AbstractIndexer.php b/Classes/Domain/Index/AbstractIndexer.php index 797bbb2..adb172e 100644 --- a/Classes/Domain/Index/AbstractIndexer.php +++ b/Classes/Domain/Index/AbstractIndexer.php @@ -122,8 +122,10 @@ abstract class AbstractIndexer implements IndexerInterface $offset = 0; $limit = $this->getLimit(); - while (($records = $this->getRecords($offset, $limit)) !== []) { - yield $records; + while (($records = $this->getRecords($offset, $limit)) !== null) { + if (!empty($records)) { + yield $records; + } $offset += $limit; } } @@ -194,7 +196,10 @@ abstract class AbstractIndexer implements IndexerInterface 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. diff --git a/Classes/Domain/Index/TcaIndexer.php b/Classes/Domain/Index/TcaIndexer.php index 39170ef..e1b03b7 100644 --- a/Classes/Domain/Index/TcaIndexer.php +++ b/Classes/Domain/Index/TcaIndexer.php @@ -49,11 +49,14 @@ class TcaIndexer extends AbstractIndexer $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); if ($records === []) { - return []; + return null; } $this->tcaTableService->filterRecordsByRootLineBlacklist($records);