Skip to content

Commit

Permalink
[TASK] Do not ignore database exceptions
Browse files Browse the repository at this point in the history
This removes a try catch block around a select query. 

When a database query is not okay for any reason, then i like to get the reason directly.
  • Loading branch information
christophlehmann authored and dkd-kaehm committed Nov 1, 2024
1 parent 094b4e5 commit cbb90e3
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Classes/Domain/Index/Queue/UpdateHandler/GarbageHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,18 +241,14 @@ protected function isRelatedQueueRecordMarkedAsIndexed(string $table, array $rec
public function getRecordWithFieldRelevantForGarbageCollection(string $table, int $uid): ?array
{
$garbageCollectionRelevantFields = $this->tcaService->getVisibilityAffectingFieldsByTable($table);
try {
$queryBuilder = $this->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll();
$row = $queryBuilder
->select(...GeneralUtility::trimExplode(',', $garbageCollectionRelevantFields, true))
->from($table)
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \Doctrine\DBAL\ParameterType::INTEGER)))
->executeQuery()
->fetchAssociative();
} catch (Throwable) {
$row = false;
}
$queryBuilder = $this->getQueryBuilderForTable($table);
$queryBuilder->getRestrictions()->removeAll();
$row = $queryBuilder
->select(...GeneralUtility::trimExplode(',', $garbageCollectionRelevantFields, true))
->from($table)
->where($queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($uid, \Doctrine\DBAL\ParameterType::INTEGER)))
->executeQuery()
->fetchAssociative();

return is_array($row) ? $row : null;
}
Expand Down

0 comments on commit cbb90e3

Please sign in to comment.