TYPO3 CMS  TYPO3_6-2
scheduler_cli_dispatch.php
Go to the documentation of this file.
1 <?php
20 if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI && basename(PATH_thisScript) == 'cli_dispatch.phpsh') {
21  $hasTask = TRUE;
22  // Create an instance of the scheduler object
24  $scheduler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Scheduler\\Scheduler');
26  $cli = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Controller\\CommandLineController');
27  // If a specific id is given in arguments, then run that task. Otherwise run scheduled tasks.
28  if ($cli->cli_isArg('-i')) {
29  $taskId = (int)$cli->cli_argValue('-i');
30  if ($taskId > 0) {
31  // Force the execution of the task even if it is disabled or no execution scheduled
32  if ($cli->cli_isArg('-f')) {
33  $task = $scheduler->fetchTask($taskId);
34  } else {
35  $whereClause = 'uid = ' . $taskId . ' AND nextexecution != 0 AND nextexecution <= ' . $GLOBALS['EXEC_TIME'];
36  list($task) = $scheduler->fetchTasksWithCondition($whereClause);
37  }
38  if ($scheduler->isValidTaskObject($task)) {
39  try {
40  $scheduler->executeTask($task);
41  } catch (\Exception $e) {
42 
43  }
44  // Record the run in the system registry
45  $scheduler->recordLastRun('cli-by-id');
46  }
47  }
48  } else {
49  // Loop as long as there are tasks
50  do {
51  // Try getting the next task and execute it
52  // If there are no more tasks to execute, an exception is thrown by \TYPO3\CMS\Scheduler\Scheduler::fetchTask()
53  try {
55  $task = $scheduler->fetchTask();
56  $hasTask = TRUE;
57  try {
58  $scheduler->executeTask($task);
59  } catch (\Exception $e) {
60  // We ignore any exception that may have been thrown during execution,
61  // as this is a background process.
62  // The exception message has been recorded to the database anyway
63  continue;
64  }
65  } catch (\OutOfBoundsException $e) {
66  $hasTask = FALSE;
67  } catch (\UnexpectedValueException $e) {
68  continue;
69  }
70  } while ($hasTask);
71  // Record the run in the system registry
72  $scheduler->recordLastRun();
73  }
74 } else {
75  die('This script must be included by the "CLI module dispatcher"');
76 }
die
Definition: index.php:6
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]