‪TYPO3CMS  ‪main
TYPO3\CMS\Scheduler\Task\AbstractTask Class Reference
Inheritance diagram for TYPO3\CMS\Scheduler\Task\AbstractTask:
TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask TYPO3\CMS\Linkvalidator\Task\ValidatorTask TYPO3\CMS\Recycler\Task\CleanerTask TYPO3\CMS\Reports\Task\SystemStatusUpdateTask TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask TYPO3\CMS\Scheduler\Task\FileStorageExtractionTask TYPO3\CMS\Scheduler\Task\FileStorageIndexingTask TYPO3\CMS\Scheduler\Task\IpAnonymizationTask TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask TYPO3\CMS\Scheduler\Task\RecyclerGarbageCollectionTask TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask TYPO3\CMS\Scheduler\Tests\Unit\Task\Fixtures\TestTask

Public Member Functions

 __construct ()
 
bool execute ()
 
string getAdditionalInformation ()
 
 setTaskUid ($id)
 
int getTaskUid ()
 
string getTaskTitle ()
 
string getTaskDescription ()
 
string getTaskClassName ()
 
bool isDisabled ()
 
 setDisabled ($flag)
 
 setRunOnNextCronJob ($flag)
 
bool getRunOnNextCronJob ()
 
 setExecutionTime ($timestamp)
 
int null getTaskGroup ()
 
 setTaskGroup ($taskGroup)
 
int getExecutionTime ()
 
 setDescription ($description)
 
string getDescription ()
 
 setScheduler ()
 
 unsetScheduler ()
 
 registerSingleExecution ($timestamp)
 
 registerRecurringExecution ($start, $interval, $end=0, $multiple=false, $cron_cmd='')
 
 setExecution (Execution $execution)
 
Execution getExecution ()
 
int getNextDueExecution ()
 
bool areMultipleExecutionsAllowed ()
 
bool isExecutionRunning ()
 
int markExecution ()
 
 unmarkExecution ($executionID, \Throwable $e=null)
 
bool unmarkAllExecutions ()
 
bool save ()
 
 stop ()
 
 remove ()
 
int getType ()
 

Public Attributes

const TYPE_SINGLE = 1
 
const TYPE_RECURRING = 2
 

Protected Member Functions

 logException (\Exception $e)
 
 getLanguageService ()
 

Protected Attributes

TYPO3 CMS Scheduler Scheduler null $scheduler
 
int $taskUid = 0
 
bool $disabled = false
 
bool $runOnNextCronJob = false
 
Execution $execution
 
int $executionTime = 0
 
string $description = ''
 
int null $taskGroup = 0
 

Detailed Description

This is the base class for all Scheduler tasks It's an abstract class, not designed to be instantiated directly All Scheduler tasks should inherit from this class

Definition at line 32 of file AbstractTask.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Scheduler\Task\AbstractTask::__construct ( )

Constructor

Reimplemented in TYPO3\CMS\Scheduler\Tests\Unit\Task\Fixtures\TestTask.

Definition at line 88 of file AbstractTask.php.

Member Function Documentation

◆ areMultipleExecutionsAllowed()

bool TYPO3\CMS\Scheduler\Task\AbstractTask::areMultipleExecutionsAllowed ( )

Returns TRUE if several runs of the task are allowed concurrently

Returns
‪bool TRUE if concurrent executions are allowed, FALSE otherwise

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 386 of file AbstractTask.php.

◆ execute()

bool TYPO3\CMS\Scheduler\Task\AbstractTask::execute ( )
abstract

This is the main method that is called when a task is executed It MUST be implemented by all classes inheriting from this one Note that there is no error handling, errors and failures are expected to be handled and logged by the client implementations. Should return TRUE on successful execution, FALSE on error.

Returns
‪bool Returns TRUE on successful execution, FALSE on error

Reimplemented in TYPO3\CMS\Linkvalidator\Task\ValidatorTask, TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask, TYPO3\CMS\Reports\Task\SystemStatusUpdateTask, TYPO3\CMS\Scheduler\Task\IpAnonymizationTask, TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask, TYPO3\CMS\Scheduler\Task\RecyclerGarbageCollectionTask, TYPO3\CMS\Scheduler\Task\FileStorageExtractionTask, TYPO3\CMS\Recycler\Task\CleanerTask, TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask, TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask, TYPO3\CMS\Scheduler\Task\FileStorageIndexingTask, TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask, and TYPO3\CMS\Scheduler\Tests\Unit\Task\Fixtures\TestTask.

◆ getAdditionalInformation()

string TYPO3\CMS\Scheduler\Task\AbstractTask::getAdditionalInformation ( )

This method is designed to return some additional information about the task, that may help to set it apart from other tasks from the same class This additional information is used - for example - in the Scheduler's BE module This method should be implemented in most task classes

Returns
‪string Information to display

Reimplemented in TYPO3\CMS\Linkvalidator\Task\ValidatorTask, TYPO3\CMS\Scheduler\Task\IpAnonymizationTask, TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask, TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandTask, TYPO3\CMS\Recycler\Task\CleanerTask, and TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask.

Definition at line 114 of file AbstractTask.php.

◆ getDescription()

string TYPO3\CMS\Scheduler\Task\AbstractTask::getDescription ( )

This method returns the description of the task

Returns
‪string Description

Definition at line 268 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$description.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\add(), and TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

◆ getExecution()

Execution TYPO3\CMS\Scheduler\Task\AbstractTask::getExecution ( )

Returns the execution object

Returns
Execution The internal execution object

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 363 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$execution.

Referenced by TYPO3\CMS\Scheduler\Task\AbstractTask\getType(), and TYPO3\CMS\Scheduler\Validation\Validator\TaskValidator\isValid().

◆ getExecutionTime()

int TYPO3\CMS\Scheduler\Task\AbstractTask::getExecutionTime ( )

This method returns the timestamp corresponding to the next execution time of the task

Returns
‪int Timestamp of next execution

Definition at line 248 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$executionTime.

◆ getLanguageService()

◆ getNextDueExecution()

int TYPO3\CMS\Scheduler\Task\AbstractTask::getNextDueExecution ( )

Returns the timestamp for next due execution of the task

Returns
‪int Date and time of the next execution as a timestamp

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 374 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

◆ getRunOnNextCronJob()

bool TYPO3\CMS\Scheduler\Task\AbstractTask::getRunOnNextCronJob ( )

This method returns the run on next cron job status of the task

Returns
‪bool TRUE if task should run on next cron job, FALSE otherwise

Definition at line 208 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$runOnNextCronJob.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

◆ getTaskClassName()

string TYPO3\CMS\Scheduler\Task\AbstractTask::getTaskClassName ( )

This method returns the class name of the scheduler task

Returns
‪string

Definition at line 164 of file AbstractTask.php.

◆ getTaskDescription()

string TYPO3\CMS\Scheduler\Task\AbstractTask::getTaskDescription ( )

This method returns the description of the scheduler task

Returns
‪string

Definition at line 154 of file AbstractTask.php.

References $GLOBALS, and TYPO3\CMS\Scheduler\Task\AbstractTask\getLanguageService().

◆ getTaskGroup()

int null TYPO3\CMS\Scheduler\Task\AbstractTask::getTaskGroup ( )

This method returns the task group (uid) of the task

Returns
‪int|null Uid of task group or null if it came back from the DB without the task group set.

Definition at line 228 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$taskGroup.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\add(), and TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

◆ getTaskTitle()

string TYPO3\CMS\Scheduler\Task\AbstractTask::getTaskTitle ( )

This method returns the title of the scheduler task

Returns
‪string

Definition at line 144 of file AbstractTask.php.

References $GLOBALS, and TYPO3\CMS\Scheduler\Task\AbstractTask\getLanguageService().

◆ getTaskUid()

◆ getType()

int TYPO3\CMS\Scheduler\Task\AbstractTask::getType ( )

Guess task type from the existing information If an interval or a cron command is defined, it's a recurring task

Returns
‪int

Definition at line 490 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\getExecution(), TYPO3\CMS\Scheduler\Task\AbstractTask\TYPE_RECURRING, and TYPO3\CMS\Scheduler\Task\AbstractTask\TYPE_SINGLE.

◆ isDisabled()

bool TYPO3\CMS\Scheduler\Task\AbstractTask::isDisabled ( )

This method returns the disabled status of the task

Returns
‪bool TRUE if task is disabled, FALSE otherwise

Definition at line 174 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$disabled.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\add(), and TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

◆ isExecutionRunning()

bool TYPO3\CMS\Scheduler\Task\AbstractTask::isExecutionRunning ( )

Returns TRUE if an instance of the task is already running

Returns
‪bool TRUE if an instance is already running, FALSE otherwise
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 397 of file AbstractTask.php.

◆ logException()

TYPO3\CMS\Scheduler\Task\AbstractTask::logException ( \Exception  $e)
protected

◆ markExecution()

int TYPO3\CMS\Scheduler\Task\AbstractTask::markExecution ( )

This method adds current execution to the execution list It also logs the execution time and mode

Returns
‪int Execution id
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 410 of file AbstractTask.php.

◆ registerRecurringExecution()

TYPO3\CMS\Scheduler\Task\AbstractTask::registerRecurringExecution (   $start,
  $interval,
  $end = 0,
  $multiple = false,
  $cron_cmd = '' 
)

Registers a recurring execution of the task

Parameters
int$start‪The first date/time where this execution should occur (timestamp)
int$intervalExecution interval in seconds
int$end‪The last date/time where this execution should occur (timestamp)
bool$multiple‪Set to FALSE if multiple executions of this task are not permitted in parallel
string$cron_cmd‪Used like in crontab (minute hour day month weekday)

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 326 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$execution, TYPO3\CMS\Scheduler\Execution\setCronCmd(), TYPO3\CMS\Scheduler\Execution\setEnd(), TYPO3\CMS\Scheduler\Execution\setInterval(), TYPO3\CMS\Scheduler\Execution\setMultiple(), and TYPO3\CMS\Scheduler\Execution\setStart().

Referenced by TYPO3\CMS\Scheduler\Controller\SchedulerModuleController\setTaskDataFromRequest().

◆ registerSingleExecution()

TYPO3\CMS\Scheduler\Task\AbstractTask::registerSingleExecution (   $timestamp)

◆ remove()

TYPO3\CMS\Scheduler\Task\AbstractTask::remove ( )

Removes the task totally from the system.

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

Definition at line 478 of file AbstractTask.php.

◆ save()

bool TYPO3\CMS\Scheduler\Task\AbstractTask::save ( )

Saves the details of the task to the database.

Returns
‪bool

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 459 of file AbstractTask.php.

◆ setDescription()

TYPO3\CMS\Scheduler\Task\AbstractTask::setDescription (   $description)

This method is used to set the description of the task

Parameters
string$description‪Description

Definition at line 258 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$description, and TYPO3\CMS\Redirects\Message\description.

Referenced by TYPO3\CMS\Scheduler\Controller\SchedulerModuleController\setTaskDataFromRequest().

◆ setDisabled()

TYPO3\CMS\Scheduler\Task\AbstractTask::setDisabled (   $flag)

This method is used to set the disabled status of the task

Parameters
bool$flag‪TRUE if task should be disabled, FALSE otherwise

Definition at line 184 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Controller\SchedulerModuleController\setTaskDataFromRequest(), and TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

◆ setExecution()

TYPO3\CMS\Scheduler\Task\AbstractTask::setExecution ( Execution  $execution)

Sets the internal execution object

Parameters
Execution$execution‪The execution to add

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 352 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$execution.

◆ setExecutionTime()

TYPO3\CMS\Scheduler\Task\AbstractTask::setExecutionTime (   $timestamp)

This method is used to set the timestamp corresponding to the next execution time of the task

Parameters
int$timestamp‪Timestamp of next execution

Definition at line 218 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

◆ setRunOnNextCronJob()

TYPO3\CMS\Scheduler\Task\AbstractTask::setRunOnNextCronJob (   $flag)

This method set the flag for next cron job execution

Parameters
bool$flag‪TRUE if task should run with the next cron job, FALSE otherwise

Definition at line 198 of file AbstractTask.php.

◆ setScheduler()

TYPO3\CMS\Scheduler\Task\AbstractTask::setScheduler ( )

Sets the internal reference to the singleton instance of the Scheduler and the logger instance in case it was unserialized

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 278 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\findNextExecutableTaskForUid(), and TYPO3\CMS\Scheduler\Task\ExecuteSchedulableCommandAdditionalFieldProvider\getAdditionalFields().

◆ setTaskGroup()

TYPO3\CMS\Scheduler\Task\AbstractTask::setTaskGroup (   $taskGroup)

This method is used to set the task group (uid) of the task

Parameters
int$taskGroup‪Uid of task group

Definition at line 238 of file AbstractTask.php.

References TYPO3\CMS\Scheduler\Task\AbstractTask\$taskGroup.

Referenced by TYPO3\CMS\Scheduler\Controller\SchedulerModuleController\setTaskDataFromRequest().

◆ setTaskUid()

TYPO3\CMS\Scheduler\Task\AbstractTask::setTaskUid (   $id)

This method is used to set the unique id of the task

Parameters
int$id‪Primary key (from the database record) of the scheduled task

Definition at line 124 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\add().

◆ stop()

TYPO3\CMS\Scheduler\Task\AbstractTask::stop ( )

Stops the task, by replacing the execution object by an empty one NOTE: the task still needs to be saved after that

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 469 of file AbstractTask.php.

◆ unmarkAllExecutions()

bool TYPO3\CMS\Scheduler\Task\AbstractTask::unmarkAllExecutions ( )

Clears all marked executions

Returns
‪bool TRUE if the clearing succeeded, FALSE otherwise
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 447 of file AbstractTask.php.

◆ unmarkExecution()

TYPO3\CMS\Scheduler\Task\AbstractTask::unmarkExecution (   $executionID,
\Throwable  $e = null 
)

Removes given execution from list

Parameters
int$executionID‪Id of the execution to remove.
\Throwable | null$e‪An exception to signal a failed execution
Deprecated:
‪will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.

Definition at line 423 of file AbstractTask.php.

◆ unsetScheduler()

TYPO3\CMS\Scheduler\Task\AbstractTask::unsetScheduler ( )

Unsets the internal reference to the singleton instance of the Scheduler and the logger instance. This is done before a task is serialized, so that the scheduler instance and the logger instance are not saved to the database

since TYPO3 v12.3, not part of TYPO3 Public API anymore.

Definition at line 291 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Domain\Repository\SchedulerTaskRepository\update().

Member Data Documentation

◆ $description

string TYPO3\CMS\Scheduler\Task\AbstractTask::$description = ''
protected

◆ $disabled

bool TYPO3\CMS\Scheduler\Task\AbstractTask::$disabled = false
protected

Disable flag, TRUE if task is disabled, FALSE otherwise

Definition at line 54 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Task\AbstractTask\isDisabled().

◆ $execution

◆ $executionTime

int TYPO3\CMS\Scheduler\Task\AbstractTask::$executionTime = 0
protected

This variable contains the time of next execution of the task

Definition at line 72 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Task\AbstractTask\getExecutionTime().

◆ $runOnNextCronJob

bool TYPO3\CMS\Scheduler\Task\AbstractTask::$runOnNextCronJob = false
protected

Run on next cron job flag, TRUE if task should run on next cronjob, FALSE otherwise

Definition at line 60 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Task\AbstractTask\getRunOnNextCronJob().

◆ $scheduler

TYPO3 CMS Scheduler Scheduler null TYPO3\CMS\Scheduler\Task\AbstractTask::$scheduler
protected

Reference to a scheduler object

Definition at line 43 of file AbstractTask.php.

◆ $taskGroup

int null TYPO3\CMS\Scheduler\Task\AbstractTask::$taskGroup = 0
protected

◆ $taskUid

int TYPO3\CMS\Scheduler\Task\AbstractTask::$taskUid = 0
protected

The unique id of the task used to identify it in the database.

Definition at line 48 of file AbstractTask.php.

Referenced by TYPO3\CMS\Scheduler\Task\AbstractTask\getTaskUid().

◆ TYPE_RECURRING

◆ TYPE_SINGLE