‪TYPO3CMS  ‪main
TYPO3\CMS\Scheduler\Scheduler Class Reference
Inheritance diagram for TYPO3\CMS\Scheduler\Scheduler:
TYPO3\CMS\Core\SingletonInterface

Public Member Functions

 __construct (LoggerInterface $logger, TaskSerializer $taskSerializer, SchedulerTaskRepository $schedulerTaskRepository)
 
bool addTask (AbstractTask $task)
 
bool executeTask (AbstractTask $task)
 
 recordLastRun ($type='cron')
 
bool removeTask (AbstractTask $task)
 
 saveTask (AbstractTask $task)
 
Task AbstractTask fetchTask ($uid=0)
 
array fetchTaskRecord ($uid)
 
array fetchTasksWithCondition ($where, $includeDisabledTasks=false)
 
bool isValidTaskObject ($task)
 
 log ($message, $status=0, $code='')
 

Public Attributes

array $extConf = array( )
 

Protected Member Functions

 cleanExecutionArrays ()
 

Protected Attributes

LoggerInterface $logger
 
TaskSerializer $taskSerializer
 
SchedulerTaskRepository $schedulerTaskRepository
 

Detailed Description

TYPO3 Scheduler. This class handles scheduling and execution of tasks.

Definition at line 35 of file Scheduler.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Scheduler\Scheduler::__construct ( LoggerInterface  $logger,
TaskSerializer  $taskSerializer,
SchedulerTaskRepository  $schedulerTaskRepository 
)

Member Function Documentation

◆ addTask()

bool TYPO3\CMS\Scheduler\Scheduler::addTask ( AbstractTask  $task)

Adds a task to the pool

Parameters
Task\AbstractTask$task‪The object representing the task to add
Returns
‪bool TRUE if the task was successfully added, FALSE otherwise
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 69 of file Scheduler.php.

◆ cleanExecutionArrays()

TYPO3\CMS\Scheduler\Scheduler::cleanExecutionArrays ( )
protected

Cleans the execution lists of the scheduled tasks, executions older than 24h are removed

Todo:
‪find a way to actually kill the job

Definition at line 79 of file Scheduler.php.

References $GLOBALS, TYPO3\CMS\Scheduler\Scheduler\log(), and TYPO3\CMS\Core\Database\Connection\PARAM_INT.

Referenced by TYPO3\CMS\Scheduler\Scheduler\__construct().

◆ executeTask()

bool TYPO3\CMS\Scheduler\Scheduler::executeTask ( AbstractTask  $task)

This method executes the given task and properly marks and records that execution It is expected to return FALSE if the task was barred from running or if it was not saved properly

Parameters
Task\AbstractTask$task‪The task to execute
Returns
‪bool Whether the task was saved successfully to the database or not
Exceptions

Definition at line 143 of file Scheduler.php.

◆ fetchTask()

Task AbstractTask TYPO3\CMS\Scheduler\Scheduler::fetchTask (   $uid = 0)

Fetches and unserializes a task object from the db. If a uid is given the object with the uid is returned, else the object representing the next due task is returned. If there are no due tasks the method throws an exception.

Parameters
int$uid‪Primary key of a task
Returns
Task\AbstractTask The fetched task object
Exceptions

Definition at line 263 of file Scheduler.php.

◆ fetchTaskRecord()

array TYPO3\CMS\Scheduler\Scheduler::fetchTaskRecord (   $uid)

This method is used to get the database record for a given task It returns the database record and not the task object

Parameters
int$uid‪Primary key of the task to get
Returns
‪array Database record for the task
See also
‪\TYPO3\CMS\Scheduler\Scheduler::fetchTask()
Exceptions

Definition at line 282 of file Scheduler.php.

◆ fetchTasksWithCondition()

array TYPO3\CMS\Scheduler\Scheduler::fetchTasksWithCondition (   $where,
  $includeDisabledTasks = false 
)

Fetches and unserializes task objects selected with some (SQL) condition Objects are returned as an array

Parameters
string$where‪Part of a SQL where clause (without the "WHERE" keyword)
bool$includeDisabledTasks‪TRUE if disabled tasks should be fetched too, FALSE otherwise
Returns
‪array List of task objects
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 302 of file Scheduler.php.

◆ isValidTaskObject()

bool TYPO3\CMS\Scheduler\Scheduler::isValidTaskObject (   $task)

This method encapsulates a very simple test for the purpose of clarity. Registered tasks are stored in the database along with a serialized task object. When a registered task is fetched, its object is unserialized. At that point, if the class corresponding to the object is not available anymore (e.g. because the extension providing it has been uninstalled), the unserialization will produce an incomplete object. This test checks whether the unserialized object is of the right (parent) class or not.

Parameters
object$task‪The object to test
Returns
‪bool TRUE if object is a task, FALSE otherwise
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 357 of file Scheduler.php.

◆ log()

TYPO3\CMS\Scheduler\Scheduler::log (   $message,
  $status = 0,
  $code = '' 
)

This is a utility method that writes some message to the BE Log It could be expanded to write to some other log

Parameters
string$message‪The message to write to the log
int$status‪Status (0 = message, 1 = error)
mixed$code‪Key for the message

Definition at line 372 of file Scheduler.php.

Referenced by TYPO3\CMS\Scheduler\Scheduler\cleanExecutionArrays().

◆ recordLastRun()

TYPO3\CMS\Scheduler\Scheduler::recordLastRun (   $type = 'cron')

This method stores information about the last run of the Scheduler into the system registry

Parameters
string$type‪Type of run (manual or command-line (assumed to be cron))

Definition at line 216 of file Scheduler.php.

◆ removeTask()

bool TYPO3\CMS\Scheduler\Scheduler::removeTask ( AbstractTask  $task)

Removes a task completely from the system.

Todo:
‪find a way to actually kill the existing jobs
Parameters
Task\AbstractTask$task‪The object representing the task to delete
Returns
‪bool TRUE if task was successfully deleted, FALSE otherwise
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 236 of file Scheduler.php.

◆ saveTask()

TYPO3\CMS\Scheduler\Scheduler::saveTask ( AbstractTask  $task)

Update a task in the pool.

Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 246 of file Scheduler.php.

Member Data Documentation

◆ $extConf

array TYPO3\CMS\Scheduler\Scheduler::$extConf = array( )

$extConf Settings from the extension manager

Definition at line 43 of file Scheduler.php.

◆ $logger

LoggerInterface TYPO3\CMS\Scheduler\Scheduler::$logger
protected

Definition at line 37 of file Scheduler.php.

Referenced by TYPO3\CMS\Scheduler\Scheduler\__construct().

◆ $schedulerTaskRepository

SchedulerTaskRepository TYPO3\CMS\Scheduler\Scheduler::$schedulerTaskRepository
protected

Definition at line 39 of file Scheduler.php.

Referenced by TYPO3\CMS\Scheduler\Scheduler\__construct().

◆ $taskSerializer

TaskSerializer TYPO3\CMS\Scheduler\Scheduler::$taskSerializer
protected

Definition at line 38 of file Scheduler.php.

Referenced by TYPO3\CMS\Scheduler\Scheduler\__construct().