From 77fd436562747cd7232bf32cf0f6e01e249bd81e Mon Sep 17 00:00:00 2001 From: Maxence Lange Date: Mon, 23 Feb 2026 10:26:22 -0100 Subject: [PATCH] force delete old events Signed-off-by: Maxence Lange --- lib/Db/EventWrapperRequest.php | 21 ++++++++++----------- lib/Service/MaintenanceService.php | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/Db/EventWrapperRequest.php b/lib/Db/EventWrapperRequest.php index b038fdee5..be6ab5f6b 100644 --- a/lib/Db/EventWrapperRequest.php +++ b/lib/Db/EventWrapperRequest.php @@ -122,19 +122,18 @@ public function getByToken(string $token): array { } /** - * delete completed entries older than a month - * - * @param bool $allOldEntries delete also not-completed entries + * delete completed entries older than a week, + * delete all entries older than a month */ - public function deleteOldEntries(bool $allOldEntries = false): void { + public function deleteOldEntries(): void { $qb = $this->getEventWrapperDeleteSql(); - $qb->where( - $qb->exprLimitInt('status', EventWrapper::STATUS_OVER), - $qb->exprLt('creation', time() - 30 * 86400) - ); - if (!$allOldEntries) { - $qb->andWhere($qb->exprLimitInt('status', EventWrapper::STATUS_OVER)); - } + $qb->where($qb->expr()->orX( + $qb->expr()->andX( + $qb->exprLimitInt('status', EventWrapper::STATUS_OVER), + $qb->exprLt('creation', time() - 604800) + ), + $qb->exprLt('creation', time() - (4 * 604800)), + )); $qb->executeStatement(); } diff --git a/lib/Service/MaintenanceService.php b/lib/Service/MaintenanceService.php index a818e2fc7..d613b4767 100644 --- a/lib/Service/MaintenanceService.php +++ b/lib/Service/MaintenanceService.php @@ -209,7 +209,7 @@ private function runMaintenance4(bool $forceRefresh = false): void { try { $this->output('Delete old and terminated FederatedEvents'); - $this->eventWrapperRequest->deleteOldEntries(false); + $this->eventWrapperRequest->deleteOldEntries(); } catch (Exception $e) { $this->logger->warning('issue while deleting old events', ['exception' => $e]); }