From d358714d0d5b89cbbc4a517f9dcf5a657e68df63 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 12 Jan 2017 14:26:09 +0100 Subject: [PATCH] BUGFIX: Handle non available records during indexing * E.g. a hidden record is edited. --- Classes/Domain/Index/TcaIndexer.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Classes/Domain/Index/TcaIndexer.php b/Classes/Domain/Index/TcaIndexer.php index 0d92abc..9592b65 100644 --- a/Classes/Domain/Index/TcaIndexer.php +++ b/Classes/Domain/Index/TcaIndexer.php @@ -82,7 +82,11 @@ class TcaIndexer implements IndexerInterface public function indexDocument($identifier) { $this->logger->info('Start indexing single record.', [$identifier]); - $this->connection->addDocument($this->tcaTableService->getTableName(), $this->getRecord($identifier)); + try { + $this->connection->addDocument($this->tcaTableService->getTableName(), $this->getRecord($identifier)); + } catch (NoRecordFoundException $e) { + $this->logger->info('Could not index document.', [$e->getMessage()]); + } $this->logger->info('Finish indexing'); } @@ -128,6 +132,7 @@ class TcaIndexer implements IndexerInterface /** * @param int $identifier * @return array + * @throws NoRecordFoundException If record could not be found. */ protected function getRecord($identifier) { @@ -137,6 +142,13 @@ class TcaIndexer implements IndexerInterface $this->tcaTableService->getWhereClause() . ' AND ' . $this->tcaTableService->getTableName() . '.uid = ' . (int) $identifier ); + + if ($record === false) { + throw new NoRecordFoundException( + 'Record could not be fetched from database: "' . $identifier . '". Perhaps record is not active.', + 1484225364 + ); + } $this->tcaTableService->prepareRecord($record); return $record;