CRM-16276 Daily jobs run by cron slip forward each day, until eventually missed
authorKen West <ken.west@internode.on.net>
Tue, 21 Apr 2015 11:53:27 +0000 (21:53 +1000)
committerKen West <ken.west@internode.on.net>
Tue, 12 May 2015 08:54:05 +0000 (18:54 +1000)
CRM/Core/ScheduledJob.php

index 6872ba2365728cabb1cc057be8a0ae83c737fea2..5d9e9ad9e90a79b9ba95a5f31edb605a3dc34d1d 100644 (file)
@@ -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() {