diff --git a/lib/Helper/DatabaseLogHandler.php b/lib/Helper/DatabaseLogHandler.php index fe3bd48988..b8cf08fc58 100644 --- a/lib/Helper/DatabaseLogHandler.php +++ b/lib/Helper/DatabaseLogHandler.php @@ -1,6 +1,6 @@ prepare('DELETE FROM `log` WHERE logdate < :maxage'); - $statement->execute(['maxage' => $cutOff]); - PdoStorageService::incrementStat('log', 'delete'); + + $statement = self::$pdo->prepare('DELETE FROM `log` WHERE logdate < :maxage LIMIT 10000'); + + do { + // Execute statement + $statement->execute(['maxage' => $cutOff]); + + // initialize number of rows deleted + $rowsDeleted = $statement->rowCount(); + + PdoStorageService::incrementStat('log', 'delete'); + + // pause for a second + sleep(2); + + } while ($rowsDeleted > 0); + } catch (\PDOException $ignored) {} } }