CleanerTask extends AbstractTask
A task that should be run regularly that deletes deleted datasets from the DB.
This class is a specific scheduler task implementation and is not part of the Public TYPO3 API.
Table of Contents
Constants
- TYPE_RECURRING = 2
- TYPE_SINGLE = 1
Properties
- $description : string
- Description for the task
- $disabled : bool
- Disable flag, TRUE if task is disabled, FALSE otherwise
- $execution : Execution
- The execution object related to the task
- $executionTime : int
- This variable contains the time of next execution of the task
- $period : int
- $runOnNextCronJob : bool
- Run on next cron job flag, TRUE if task should run on next cronjob, FALSE otherwise
- $scheduler : Scheduler|null
- Reference to a scheduler object
- $taskGroup : int|null
- Task group for this task
- $taskUid : int
- The unique id of the task used to identify it in the database.
- $tcaTables : array<string|int, mixed>
Methods
- __construct() : mixed
- Constructor
- areMultipleExecutionsAllowed() : bool
- Returns TRUE if several runs of the task are allowed concurrently
- execute() : bool
- The main method of the task. Iterates through the tables and calls the cleaning function
- getAdditionalInformation() : string
- Returns the information shown in the task-list
- getDescription() : string
- This method returns the description of the task
- getExecution() : Execution
- Returns the execution object
- getExecutionTime() : int
- This method returns the timestamp corresponding to the next execution time of the task
- getNextDueExecution() : int
- Returns the timestamp for next due execution of the task
- getPeriod() : int
- Returns the period after which a row is deleted
- getPeriodAsTimestamp() : int
- getRunOnNextCronJob() : bool
- This method returns the run on next cron job status of the task
- getTaskClassName() : string
- This method returns the class name of the scheduler task
- getTaskDescription() : string
- This method returns the description of the scheduler task
- getTaskGroup() : int|null
- This method returns the task group (uid) of the task
- getTaskTitle() : string
- This method returns the title of the scheduler task
- getTaskUid() : int
- This method returns the unique id of the task
- getTcaTables() : array<string|int, mixed>
- Returns the TCA-tables which are cleaned
- getType() : int
- Guess task type from the existing information If an interval or a cron command is defined, it's a recurring task
- isDisabled() : bool
- This method returns the disabled status of the task
- isExecutionRunning() : bool
- Returns TRUE if an instance of the task is already running
- markExecution() : int
- This method adds current execution to the execution list It also logs the execution time and mode
- registerRecurringExecution() : mixed
- Registers a recurring execution of the task
- registerSingleExecution() : mixed
- Registers a single execution of the task
- remove() : mixed
- Removes the task totally from the system.
- save() : bool
- Saves the details of the task to the database.
- setDescription() : void
- This method is used to set the description of the task
- setDisabled() : mixed
- This method is used to set the disabled status of the task
- setExecution() : mixed
- Sets the internal execution object
- setExecutionTime() : mixed
- This method is used to set the timestamp corresponding to the next execution time of the task
- setPeriod() : mixed
- Sets the period after which a row is deleted
- setRunOnNextCronJob() : mixed
- This method set the flag for next cron job execution
- setScheduler() : mixed
- Sets the internal reference to the singleton instance of the Scheduler and the logger instance in case it was unserialized
- setTaskGroup() : mixed
- This method is used to set the task group (uid) of the task
- setTaskUid() : void
- This method is used to set the unique id of the task
- setTcaTables() : mixed
- Sets the TCA-tables which are cleaned
- stop() : mixed
- Stops the task, by replacing the execution object by an empty one NOTE: the task still needs to be saved after that
- unmarkAllExecutions() : bool
- Clears all marked executions
- unmarkExecution() : mixed
- Removes given execution from list
- unsetScheduler() : mixed
- Unsets the internal reference to the singleton instance of the Scheduler and the logger instance.
- cleanTable() : bool
- Executes the delete-query for the given table
- getLanguageService() : LanguageService|null
- logException() : mixed
Constants
TYPE_RECURRING
    public
        mixed
    TYPE_RECURRING
    = 2
    
    
    
    
TYPE_SINGLE
    public
        mixed
    TYPE_SINGLE
    = 1
    
    
    
    
Properties
$description
Description for the task
        protected
            string
    $description
     = ''
    
    
    
    
    
$disabled
Disable flag, TRUE if task is disabled, FALSE otherwise
        protected
            bool
    $disabled
     = false
    
    
    
    
    
$execution
The execution object related to the task
        protected
            Execution
    $execution
    
    
    
    
    
    
$executionTime
This variable contains the time of next execution of the task
        protected
            int
    $executionTime
     = 0
    
    
    
    
    
$period
        protected
            int
    $period
     = 0
    
        The time period, after which the rows are deleted
$runOnNextCronJob
Run on next cron job flag, TRUE if task should run on next cronjob, FALSE otherwise
        protected
            bool
    $runOnNextCronJob
     = false
    
    
    
    
    
$scheduler
Reference to a scheduler object
        protected
            Scheduler|null
    $scheduler
    
    
    
    
    
    
$taskGroup
Task group for this task
        protected
            int|null
    $taskGroup
     = 0
    
    
    
    
    
$taskUid
The unique id of the task used to identify it in the database.
        protected
            int
    $taskUid
     = 0
    
    
    
    
    
$tcaTables
        protected
            array<string|int, mixed>
    $tcaTables
     = []
    
        The tables to clean
Methods
__construct()
Constructor
    public
                    __construct() : mixed
    areMultipleExecutionsAllowed()
Returns TRUE if several runs of the task are allowed concurrently
    public
                    areMultipleExecutionsAllowed() : bool
    since TYPO3 v12.3, not part of TYPO3 Public API anymore.
Return values
bool —TRUE if concurrent executions are allowed, FALSE otherwise
execute()
The main method of the task. Iterates through the tables and calls the cleaning function
    public
                    execute() : bool
    Return values
bool —Returns TRUE on successful execution, FALSE on error
getAdditionalInformation()
Returns the information shown in the task-list
    public
                    getAdditionalInformation() : string
    Return values
string —Information-text fot the scheduler task-list
getDescription()
This method returns the description of the task
    public
                    getDescription() : string
    Return values
string —Description
getExecution()
Returns the execution object
    public
                    getExecution() : Execution
    since TYPO3 v12.3, not part of TYPO3 Public API anymore.
Return values
Execution —The internal execution object
getExecutionTime()
This method returns the timestamp corresponding to the next execution time of the task
    public
                    getExecutionTime() : int
    Return values
int —Timestamp of next execution
getNextDueExecution()
Returns the timestamp for next due execution of the task
    public
                    getNextDueExecution() : int
    since TYPO3 v12.3, not part of TYPO3 Public API anymore.
Return values
int —Date and time of the next execution as a timestamp
getPeriod()
Returns the period after which a row is deleted
    public
                    getPeriod() : int
    Return values
intgetPeriodAsTimestamp()
    public
                    getPeriodAsTimestamp() : int
    Return values
intgetRunOnNextCronJob()
This method returns the run on next cron job status of the task
    public
                    getRunOnNextCronJob() : bool
    Return values
bool —TRUE if task should run on next cron job, FALSE otherwise
getTaskClassName()
This method returns the class name of the scheduler task
    public
                    getTaskClassName() : string
    Return values
stringgetTaskDescription()
This method returns the description of the scheduler task
    public
                    getTaskDescription() : string
    Return values
stringgetTaskGroup()
This method returns the task group (uid) of the task
    public
                    getTaskGroup() : int|null
    Return values
int|null —Uid of task group or null if it came back from the DB without the task group set.
getTaskTitle()
This method returns the title of the scheduler task
    public
                    getTaskTitle() : string
    Return values
stringgetTaskUid()
This method returns the unique id of the task
    public
                    getTaskUid() : int
    Return values
int —The id of the task
getTcaTables()
Returns the TCA-tables which are cleaned
    public
                    getTcaTables() : array<string|int, mixed>
    Return values
array<string|int, mixed>getType()
Guess task type from the existing information If an interval or a cron command is defined, it's a recurring task
    public
                    getType() : int
    Return values
intisDisabled()
This method returns the disabled status of the task
    public
                    isDisabled() : bool
    Return values
bool —TRUE if task is disabled, FALSE otherwise
isExecutionRunning()
Returns TRUE if an instance of the task is already running
    public
                    isExecutionRunning() : bool
    will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.
Return values
bool —TRUE if an instance is already running, FALSE otherwise
markExecution()
This method adds current execution to the execution list It also logs the execution time and mode
    public
                    markExecution() : int
    will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.
Return values
int —Execution id
registerRecurringExecution()
Registers a recurring execution of the task
    public
                    registerRecurringExecution(int $start, int $interval[, int $end = 0 ][, bool $multiple = false ][, string $cron_cmd = '' ]) : mixed
    Parameters
- $start : int
- 
                    The first date/time where this execution should occur (timestamp) 
- $interval : int
- 
                    Execution interval in seconds 
- $end : int = 0
- 
                    The last date/time where this execution should occur (timestamp) 
- $multiple : bool = false
- 
                    Set to FALSE if multiple executions of this task are not permitted in parallel 
- $cron_cmd : string = ''
- 
                    Used like in crontab (minute hour day month weekday) 
since TYPO3 v12.3, not part of TYPO3 Public API anymore.
registerSingleExecution()
Registers a single execution of the task
    public
                    registerSingleExecution(int $timestamp) : mixed
    Parameters
- $timestamp : int
- 
                    Timestamp of the next execution 
since TYPO3 v12.3, not part of TYPO3 Public API anymore.
remove()
Removes the task totally from the system.
    public
                    remove() : mixed
    will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.
save()
Saves the details of the task to the database.
    public
                    save() : bool
    since TYPO3 v12.3, not part of TYPO3 Public API anymore.
Return values
boolsetDescription()
This method is used to set the description of the task
    public
                    setDescription(string $description) : void
    Parameters
- $description : string
- 
                    Description 
setDisabled()
This method is used to set the disabled status of the task
    public
                    setDisabled(bool $flag) : mixed
    Parameters
- $flag : bool
- 
                    TRUE if task should be disabled, FALSE otherwise 
setExecution()
Sets the internal execution object
    public
                    setExecution(Execution $execution) : mixed
    Parameters
- $execution : Execution
- 
                    The execution to add 
since TYPO3 v12.3, not part of TYPO3 Public API anymore.
setExecutionTime()
This method is used to set the timestamp corresponding to the next execution time of the task
    public
                    setExecutionTime(int $timestamp) : mixed
    Parameters
- $timestamp : int
- 
                    Timestamp of next execution 
setPeriod()
Sets the period after which a row is deleted
    public
                    setPeriod(int $period) : mixed
    Parameters
- $period : int
setRunOnNextCronJob()
This method set the flag for next cron job execution
    public
                    setRunOnNextCronJob(bool $flag) : mixed
    Parameters
- $flag : bool
- 
                    TRUE if task should run with the next cron job, FALSE otherwise 
setScheduler()
Sets the internal reference to the singleton instance of the Scheduler and the logger instance in case it was unserialized
    public
                    setScheduler() : mixed
    since TYPO3 v12.3, not part of TYPO3 Public API anymore.
setTaskGroup()
This method is used to set the task group (uid) of the task
    public
                    setTaskGroup(int $taskGroup) : mixed
    Parameters
- $taskGroup : int
- 
                    Uid of task group 
setTaskUid()
This method is used to set the unique id of the task
    public
                    setTaskUid(int $id) : void
    Parameters
- $id : int
- 
                    Primary key (from the database record) of the scheduled task 
setTcaTables()
Sets the TCA-tables which are cleaned
    public
                    setTcaTables([array<string|int, mixed> $tcaTables = [] ]) : mixed
    Parameters
- $tcaTables : array<string|int, mixed> = []
stop()
Stops the task, by replacing the execution object by an empty one NOTE: the task still needs to be saved after that
    public
                    stop() : mixed
    since TYPO3 v12.3, not part of TYPO3 Public API anymore.
unmarkAllExecutions()
Clears all marked executions
    public
                    unmarkAllExecutions() : bool
    will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.
Return values
bool —TRUE if the clearing succeeded, FALSE otherwise
unmarkExecution()
Removes given execution from list
    public
                    unmarkExecution(int $executionID[, Throwable|null $e = null ]) : mixed
    will be removed in TYPO3 v13.0. Use SchedulerTaskRepository instead.
Parameters
- $executionID : int
- 
                    Id of the execution to remove. 
- $e : Throwable|null = null
- 
                    An exception to signal a failed execution 
unsetScheduler()
Unsets the internal reference to the singleton instance of the Scheduler and the logger instance.
    public
                    unsetScheduler() : mixed
    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.
cleanTable()
Executes the delete-query for the given table
    protected
                    cleanTable(string $tableName) : bool
    Parameters
- $tableName : string
Return values
boolgetLanguageService()
    protected
                    getLanguageService() : LanguageService|null
    Return values
LanguageService|nulllogException()
    protected
                    logException(Exception $e) : mixed
    Parameters
- $e : Exception