Example #1
0
 /**
  * Execute tasks in loop
  */
 protected function loopTasks()
 {
     do {
         // Try getting the next task and execute it
         // If there are no more tasks to execute, an exception is thrown by \TYPO3\CMS\Scheduler\Scheduler::fetchTask()
         try {
             /** @var $task \TYPO3\CMS\Scheduler\Task\AbstractTask */
             $task = $this->scheduler->fetchTask();
             try {
                 $this->scheduler->executeTask($task);
             } catch (\Exception $e) {
                 // We ignore any exception that may have been thrown during execution,
                 // as this is a background process.
                 // The exception message has been recorded to the database anyway
                 continue;
             }
         } catch (\OutOfBoundsException $e) {
             $this->hasTask = false;
         } catch (\UnexpectedValueException $e) {
             continue;
         }
     } while ($this->hasTask);
     // Record the run in the system registry
     $this->scheduler->recordLastRun();
 }
 /**
  * Execute a single task
  *
  * @param int $taskId
  * @param bool $forceExecution
  */
 protected function executeSingleTask($taskId, $forceExecution)
 {
     // Force the execution of the task even if it is disabled or no execution scheduled
     if ($forceExecution) {
         $task = $this->scheduler->fetchTask($taskId);
     } else {
         $whereClause = 'uid = ' . (int) $taskId . ' AND nextexecution != 0 AND nextexecution <= ' . (int) $GLOBALS['EXEC_TIME'];
         list($task) = $this->scheduler->fetchTasksWithCondition($whereClause);
     }
     if ($this->scheduler->isValidTaskObject($task)) {
         try {
             $this->scheduler->executeTask($task);
         } catch (\Exception $e) {
         }
         // Record the run in the system registry
         $this->scheduler->recordLastRun('cli-by-id');
     }
 }
Example #3
0
 /**
  * Removes the task totally from the system.
  *
  * @return void
  */
 public function remove()
 {
     $this->scheduler->removeTask($this);
 }
 /**
  * Extend the method to cleanup up the log table aswell
  *
  * @see tx_scheduler::cleanExecutionArrays()
  */
 protected function cleanExecutionArrays()
 {
     parent::cleanExecutionArrays();
     $this->cleanupLog();
 }