Fix SQL in cleaning up old notifications

Subtracting numbers from datetime causes wrong value, or raises error depending on MySQL version/configurations
This commit is contained in:
mecab 2018-01-31 09:40:29 -06:00
parent 2dfe1751f3
commit be1b57a838

View File

@ -190,7 +190,7 @@ class Notification extends Mail {
public function cleanupNotifications($days=7) {
$failed = 0;
$this->deleted = 0;
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE time < (NOW() - ? * 24 * 60 * 60)");
$stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE time < (NOW() - INTERVAL ? DAY)");
if (! ($this->checkStmt($stmt) && $stmt->bind_param('i', $days) && $stmt->execute())) {
$failed++;
} else {