Skip to content

Commit

Permalink
CRM-16276 Daily jobs run by cron slip forward each day, until eventua…
Browse files Browse the repository at this point in the history
…lly missed
  • Loading branch information
kenwest committed May 12, 2015
1 parent b2e40a0 commit d0be153
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions CRM/Core/ScheduledJob.php
Expand Up @@ -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() {
Expand Down

0 comments on commit d0be153

Please sign in to comment.