From 1cd05a06fafcca6d115ec4e4b210704439c1ab14 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 12 May 2022 09:51:37 +0200 Subject: [PATCH] Always free the DB result in QBMapper::findEntities Without this patch it only happened if the code ran through without any errors. Now the result is also freed in the case of an error. Signed-off-by: Christoph Wurst --- lib/public/AppFramework/Db/QBMapper.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/public/AppFramework/Db/QBMapper.php b/lib/public/AppFramework/Db/QBMapper.php index fa753a09dcf..2491fd83f4a 100644 --- a/lib/public/AppFramework/Db/QBMapper.php +++ b/lib/public/AppFramework/Db/QBMapper.php @@ -334,16 +334,15 @@ abstract class QBMapper { */ protected function findEntities(IQueryBuilder $query): array { $result = $query->executeQuery(); - - $entities = []; - - while ($row = $result->fetch()) { - $entities[] = $this->mapRowToEntity($row); + try { + $entities = []; + while ($row = $result->fetch()) { + $entities[] = $this->mapRowToEntity($row); + } + return $entities; + } finally { + $result->closeCursor(); } - - $result->closeCursor(); - - return $entities; } -- 2.39.5