From: Ken West Date: Tue, 21 Apr 2015 11:53:27 +0000 (+1000) Subject: CRM-16276 Daily jobs run by cron slip forward each day, until eventually missed X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=d0be1535d809b206890bcd4f72ebd4ba8fb1c86d;p=civicrm-core.git CRM-16276 Daily jobs run by cron slip forward each day, until eventually missed --- diff --git a/CRM/Core/ScheduledJob.php b/CRM/Core/ScheduledJob.php index 6872ba2365..5d9e9ad9e9 100644 --- a/CRM/Core/ScheduledJob.php +++ b/CRM/Core/ScheduledJob.php @@ -101,23 +101,19 @@ class CRM_Core_ScheduledJob { 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() {