Skip to content

Commit

Permalink
Merge pull request #39297 from nextcloud/fix/dav/close-cursor
Browse files Browse the repository at this point in the history
fix(dav): close cursor when fetching max id
  • Loading branch information
nickvergessen authored Jul 12, 2023
2 parents 4882e5c + 9206c0f commit e9ac028
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3139,7 +3139,9 @@ public function pruneOutdatedSyncTokens(int $keep = 10_000): int {
$query->select($query->func()->max('id'))
->from('calendarchanges');

$maxId = $query->executeQuery()->fetchOne();
$result = $query->executeQuery();
$maxId = (int) $result->fetchOne();
$result->closeCursor();
if (!$maxId || $maxId < $keep) {
return 0;
}
Expand Down
4 changes: 3 additions & 1 deletion apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,9 @@ public function pruneOutdatedSyncTokens(int $keep = 10_000): int {
$query->select($query->func()->max('id'))
->from('addressbookchanges');

$maxId = $query->executeQuery()->fetchOne();
$result = $query->executeQuery();
$maxId = (int) $result->fetchOne();
$result->closeCursor();
if (!$maxId || $maxId < $keep) {
return 0;
}
Expand Down

0 comments on commit e9ac028

Please sign in to comment.