BUGFIX: Handle non available records during indexing

* E.g. a hidden record is edited.
This commit is contained in:
Daniel Siepmann 2017-01-12 14:26:09 +01:00
parent 1878209b51
commit d358714d0d
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -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;