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>
*/
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;
}