From df7866b8765875787f447723fef89fc5991c1d10 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Sun, 25 Sep 2022 04:30:28 -0700 Subject: [PATCH] Clean up cursor when done --- lib/Db/TimelineQueryDays.php | 14 ++++++++++---- lib/Db/TimelineWrite.php | 4 +++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/Db/TimelineQueryDays.php b/lib/Db/TimelineQueryDays.php index 6ff669ae..01974df9 100644 --- a/lib/Db/TimelineQueryDays.php +++ b/lib/Db/TimelineQueryDays.php @@ -49,9 +49,11 @@ trait TimelineQueryDays { private function getFilecacheJoinQuery(IQueryBuilder &$query, Folder &$folder, bool $recursive) { // Subquery to get storage and path $subQuery = $query->getConnection()->getQueryBuilder(); - $finfo = $subQuery->select('path', 'storage')->from('filecache')->where( + $cursor = $subQuery->select('path', 'storage')->from('filecache')->where( $subQuery->expr()->eq('fileid', $subQuery->createNamedParameter($folder->getId())), - )->executeQuery()->fetch(); + )->executeQuery(); + $finfo = $cursor->fetch(); + $cursor->closeCursor(); if (empty($finfo)) { throw new \Exception("Folder not found"); } @@ -104,7 +106,9 @@ trait TimelineQueryDays { $transform($query, $uid); } - $rows = $query->executeQuery()->fetchAll(); + $cursor = $query->executeQuery(); + $rows = $cursor->fetchAll(); + $cursor->closeCursor(); return $this->processDays($rows); } @@ -143,7 +147,9 @@ trait TimelineQueryDays { $transform($query, $uid); } - $rows = $query->executeQuery()->fetchAll(); + $cursor = $query->executeQuery(); + $rows = $cursor->fetchAll(); + $cursor->closeCursor(); return $this->processDay($rows); } } diff --git a/lib/Db/TimelineWrite.php b/lib/Db/TimelineWrite.php index bc60c957..c95b7685 100644 --- a/lib/Db/TimelineWrite.php +++ b/lib/Db/TimelineWrite.php @@ -61,7 +61,9 @@ class TimelineWrite { $query->select('fileid', 'mtime') ->from('memories') ->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT))); - $prevRow = $query->executeQuery()->fetch(); + $cursor = $query->executeQuery(); + $prevRow = $cursor->fetch(); + $cursor->closeCursor(); if ($prevRow && !$force && intval($prevRow['mtime']) === $mtime) { return 1; }