From dc6ea08ca490c889f4e85bd697e6bdffb95a22f4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 2 May 2025 14:03:45 +0300 Subject: [PATCH] add workaround for due tasks because housekeeping is not run every minute, fix last_run not updated to NOW() in the db --- classes/PluginHost.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/classes/PluginHost.php b/classes/PluginHost.php index 9bdf7c0b4..8bde8df3f 100644 --- a/classes/PluginHost.php +++ b/classes/PluginHost.php @@ -965,7 +965,9 @@ class PluginHost { Debug::log("Checking scheduled task: $task_name, last run: $last_run"); - if ($task['cron']->isDue($last_run)) { + // because we don't schedule tasks every minute, we assume that task is due if its + // next estimated run based on previous timestamp is in the past + if ($task['cron']->getNextRunDate($last_run)->getTimestamp() - time() < 0) { Debug::log("Task $task_name is due, executing..."); $task_started = time(); @@ -977,7 +979,7 @@ class PluginHost { Debug::log("Task $task_name has finished in $task_duration seconds with RC=$rc, recording timestamp..."); if ($task_record) { - $task_record->last_run = time(); + $task_record->last_run = Db::NOW(); $task_record->last_duration = $task_duration; $task_record->last_rc = $rc;