]> source.dussan.org Git - nextcloud-server.git/commitdiff
Always free the DB result in QBMapper::findEntities 32344/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 12 May 2022 07:51:37 +0000 (09:51 +0200)
committerChristoph Wurst <christoph@winzerhof-wurst.at>
Thu, 12 May 2022 07:51:37 +0000 (09:51 +0200)
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 <christoph@winzerhof-wurst.at>
lib/public/AppFramework/Db/QBMapper.php

index fa753a09dcfaab6c40d35d175edf61b30ec73c5c..2491fd83f4a646aa4938428e8d84de0f9b47d51c 100644 (file)
@@ -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;
        }