/** * Wraps the executeTask method * * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task The task to execute * @return boolean Whether the task was saved successfully to the database or not * @throws \Exception */ public function executeTask(\TYPO3\CMS\Scheduler\Task\AbstractTask $task) { $taskUid = $task->getTaskUid(); // log start $logUid = $this->logStart($taskUid); $failure = null; try { $result = parent::executeTask($task); } catch (\Exception $e) { $failure = $e; } if ($result || $failure) { $returnMessage = ''; if ($task instanceof \AOE\SchedulerTimeline\Interfaces\ReturnMessage || is_callable(array($task, 'getReturnMessage'))) { $returnMessage = $task->getReturnMessage(); } // log end $this->logEnd($logUid, $failure, $returnMessage); } else { // task was not executed, because another task was running // and multiple execution is not allowed for this task $this->removeLog($logUid); } if ($failure instanceof \Exception) { throw $failure; } return $result; }
/** * Updates a task in the pool * * @param Task\AbstractTask $task Scheduler task object * @return bool False if submitted task was not of proper class */ public function saveTask(Task\AbstractTask $task) { $taskUid = $task->getTaskUid(); if (!empty($taskUid)) { try { $executionTime = $task->getNextDueExecution(); $task->setExecutionTime($executionTime); } catch (\Exception $e) { $task->setDisabled(true); $executionTime = 0; } $task->unsetScheduler(); $fields = array('nextexecution' => $executionTime, 'disable' => $task->isDisabled(), 'description' => $task->getDescription(), 'task_group' => $task->getTaskGroup(), 'serialized_task_object' => serialize($task)); $result = $this->getDatabaseConnection()->exec_UPDATEquery('tx_scheduler_task', 'uid = ' . $taskUid, $fields); } else { $result = false; } if ($result) { $this->scheduleNextSchedulerRunUsingAtDaemon(); } return $result; }
/** * Updates a task in the pool * * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task Scheduler task object * @return boolean False if submitted task was not of proper class */ public function saveTask(\TYPO3\CMS\Scheduler\Task\AbstractTask $task) { $taskUid = $task->getTaskUid(); if (!empty($taskUid)) { try { $executionTime = $task->getNextDueExecution(); $task->setExecutionTime($executionTime); } catch (\Exception $e) { $task->setDisabled(TRUE); $executionTime = 0; } $task->unsetScheduler(); $fields = array('nextexecution' => $executionTime, 'disable' => $task->isDisabled(), 'serialized_task_object' => serialize($task)); $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_scheduler_task', 'uid = ' . $taskUid, $fields); } else { $result = FALSE; } if ($result) { $this->scheduleNextSchedulerRunUsingAtDaemon(); } return $result; }