mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Issue #36644: Fix pruneOutdatedSyncTokens for CalDAV
pruneOutdatedSyncTokens accidentally deletes all entries of the calendarchanges table instead of leaving $limit elements in the table Signed-off-by: Christof Arnosti <charno@charno.ch>
This commit is contained in:
parent
5ad24991d7
commit
73fb2997f4
2 changed files with 22 additions and 4 deletions
|
|
@ -3134,10 +3134,19 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
|
|||
if ($keep < 0) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select($query->func()->max('id'))
|
||||
->from('calendarchanges');
|
||||
|
||||
$maxId = $query->executeQuery()->fetchOne();
|
||||
if (!$maxId || $maxId < $keep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->delete('calendarchanges')
|
||||
->orderBy('id', 'DESC')
|
||||
->setFirstResult($keep);
|
||||
->where($query->expr()->lte('id', $query->createNamedParameter($maxId - $keep, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
|
||||
return $query->executeStatement();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1399,10 +1399,19 @@ class CardDavBackend implements BackendInterface, SyncSupport {
|
|||
if ($keep < 0) {
|
||||
throw new \InvalidArgumentException();
|
||||
}
|
||||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->select($query->func()->max('id'))
|
||||
->from('addressbookchanges');
|
||||
|
||||
$maxId = $query->executeQuery()->fetchOne();
|
||||
if (!$maxId || $maxId < $keep) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$query = $this->db->getQueryBuilder();
|
||||
$query->delete('addressbookchanges')
|
||||
->orderBy('id', 'DESC')
|
||||
->setFirstResult($keep);
|
||||
->where($query->expr()->lte('id', $query->createNamedParameter($maxId - $keep, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
|
||||
return $query->executeStatement();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue