diff options
author | Faraz Samapoor <f.samapoor@gmail.com> | 2023-06-27 19:07:09 +0330 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-27 19:07:09 +0330 |
commit | bbfe2fb821f00713f46fd896a41dfc62cc02c31a (patch) | |
tree | 22923a6d3a78f7f1d780e958ff118a669c6c8c63 /apps/dav/lib/CalDAV | |
parent | 8c64ccae01ef3143a47dcca0b7ddb115d601c2f1 (diff) | |
parent | 266436b76788d14e061bbe1f013bc052edc8041f (diff) | |
download | nextcloud-server-bbfe2fb821f00713f46fd896a41dfc62cc02c31a.tar.gz nextcloud-server-bbfe2fb821f00713f46fd896a41dfc62cc02c31a.zip |
Merge branch 'master' into replace_strpos_calls_in_dav_app
Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
Diffstat (limited to 'apps/dav/lib/CalDAV')
-rw-r--r-- | apps/dav/lib/CalDAV/CalDavBackend.php | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index 1cdb705ac92..94fe9acf356 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -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(); } |