From be1b57a8380c6fb47668a1583523722242125026 Mon Sep 17 00:00:00 2001 From: mecab Date: Wed, 31 Jan 2018 09:40:29 -0600 Subject: [PATCH] Fix SQL in cleaning up old notifications Subtracting numbers from datetime causes wrong value, or raises error depending on MySQL version/configurations --- include/classes/notification.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/classes/notification.class.php b/include/classes/notification.class.php index 48c64e37..f8d0151d 100644 --- a/include/classes/notification.class.php +++ b/include/classes/notification.class.php @@ -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 {