Skip to content

Commit 938e2c1

Browse files
committed
fix(dav): use absolute cutoff for sync token pruning
Signed-off-by: mooons <10822203+mooons@users.noreply.github.com>
1 parent d56ad83 commit 938e2c1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

apps/dav/lib/CalDAV/CalDavBackend.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3619,11 +3619,13 @@ public function pruneOutdatedSyncTokens(int $keep, int $retention): int {
36193619
return 0;
36203620
}
36213621

3622+
$cutoff = max(0, time() - $retention);
3623+
36223624
$query = $this->db->getQueryBuilder();
36233625
$query->delete('calendarchanges')
36243626
->where(
36253627
$query->expr()->lte('id', $query->createNamedParameter($maxId - $keep, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT),
3626-
$query->expr()->lte('created_at', $query->createNamedParameter($retention)),
3628+
$query->expr()->lte('created_at', $query->createNamedParameter($cutoff, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT),
36273629
);
36283630
return $query->executeStatement();
36293631
}

apps/dav/lib/CardDAV/CardDavBackend.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1496,11 +1496,13 @@ public function pruneOutdatedSyncTokens(int $keep, int $retention): int {
14961496
return 0;
14971497
}
14981498

1499+
$cutoff = max(0, time() - $retention);
1500+
14991501
$query = $this->db->getQueryBuilder();
15001502
$query->delete('addressbookchanges')
15011503
->where(
15021504
$query->expr()->lte('id', $query->createNamedParameter($maxId - $keep, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT),
1503-
$query->expr()->lte('created_at', $query->createNamedParameter($retention)),
1505+
$query->expr()->lte('created_at', $query->createNamedParameter($cutoff, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT),
15041506
);
15051507
return $query->executeStatement();
15061508
}

0 commit comments

Comments
 (0)