Example #1
0
 /**
  * @param CM_Clockwork_Event $event
  * @return boolean
  */
 protected function _shouldRun(CM_Clockwork_Event $event)
 {
     $lastRuntime = $this->_storage->getLastRuntime($event);
     $base = $lastRuntime ?: clone $this->_startTime;
     $dateTimeString = $event->getDateTimeString();
     if (!$this->_isIntervalEvent($event)) {
         // do not set timezone for interval-based events due to buggy behaviour with timezones that use
         $base->setTimezone($this->_timeZone);
         // daylight saving time, see https://bugs.php.net/bug.php?id=51051
     }
     $nextExecutionTime = clone $base;
     $nextExecutionTime->modify($dateTimeString);
     if ($lastRuntime) {
         if ($nextExecutionTime <= $base) {
             $nextExecutionTime = $this->_getCurrentDateTime()->modify($dateTimeString);
         }
         $shouldRun = $nextExecutionTime > $base && $this->_getCurrentDateTime() >= $nextExecutionTime;
     } else {
         if ($nextExecutionTime < $base) {
             $nextExecutionTime = $this->_getCurrentDateTime()->modify($dateTimeString);
         }
         $shouldRun = $nextExecutionTime >= $base && $this->_getCurrentDateTime() >= $nextExecutionTime;
     }
     return $shouldRun;
 }
Example #2
0
 /**
  * @param CM_Clockwork_Event $event
  */
 protected function _runEvent(CM_Clockwork_Event $event)
 {
     $process = $this->_getProcess();
     $lastRuntime = $this->_storage->getLastRuntime($event);
     $startTime = $this->_getCurrentDateTime();
     $forkHandler = $process->fork(function () use($event, $lastRuntime) {
         $event->run($lastRuntime);
     });
     $this->_markRunning($event, $forkHandler->getIdentifier(), $startTime);
 }