From d0be1535d809b206890bcd4f72ebd4ba8fb1c86d Mon Sep 17 00:00:00 2001 From: Ken West Date: Tue, 21 Apr 2015 21:53:27 +1000 Subject: [PATCH] CRM-16276 Daily jobs run by cron slip forward each day, until eventually missed --- CRM/Core/ScheduledJob.php | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/CRM/Core/ScheduledJob.php b/CRM/Core/ScheduledJob.php index 6872ba236572..5d9e9ad9e90a 100644 --- a/CRM/Core/ScheduledJob.php +++ b/CRM/Core/ScheduledJob.php @@ -101,23 +101,19 @@ public function needsRunning() { return TRUE; case 'Hourly': - $now = CRM_Utils_Date::currentDBDate(); - $hourAgo = strtotime('-1 hour', strtotime($now)); - $lastRun = strtotime($this->last_run); - if ($lastRun < $hourAgo) { - return TRUE; - } + $format = 'YmdH'; + break; case 'Daily': - $now = CRM_Utils_Date::currentDBDate(); - $dayAgo = strtotime('-1 day', strtotime($now)); - $lastRun = strtotime($this->last_run); - if ($lastRun < $dayAgo) { - return TRUE; - } + $format = 'Ymd'; + break; } - return FALSE; + $now = CRM_Utils_Date::currentDBDate(); + $lastTime = date($format, strtotime($this->last_run)); + $thisTime = date($format, strtotime($now)); + + return ($lastTime <> $thisTime); } public function __destruct() {