Table garbage collection task
Deprecated since version 14.0
The previous configuration method using
$GLOBALS
has been deprecated and will be removed in TYPO3 v15.
See also: Changelog Deprecation: #107550 - Table Garbage Collection Task configuration via $GLOBALS
The table garbage collection task can take a more elaborate configuration which is detailed below.
Table of contents
Using the garbage collection task
The task can be registered to clean up a particular table, in which case you simply choose the table and the minimum age of the records to delete from the task configuration screen.

Configuring the table garbage collection task
In case no minimum age is choosen, the configured
expire
is used.

Configuring the table garbage collection task with default expire period
It is also possible to clean up all configured table by checking the "Clean all available tables" box.
The configuration for
the tables to clean up is stored in the TCA of table tx_
, in
field tables
.
This configuration is an array with the table names as fields and the following entries:
- option
expire
can be used to point to a table field containing an expiry timestamp. This timestamp will then be used to decide whether a record has expired or not. If its timestamp is in the past, the record will be deleted.Field - if a table has no expiry field, one can use a combination of a date
field and an expiry period to decide which records should be deleted.
The corresponding options are
date
andField expire
. The expiry period is expressed in days.Period
Example: Configure additional tables for the "Garbage Collection" task
<?php
use TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask;
if (isset($GLOBALS['TCA']['tx_scheduler_task'])) {
$garbageCollectionTables =& $GLOBALS['TCA']['tx_scheduler_task']['types'][TableGarbageCollectionTask::class]['taskOptions']['tables'];
$garbageCollectionTables = array_replace($garbageCollectionTables ?? [], [
'tx_myextension_my_table' => [
'dateField' => 'tstamp',
'expirePeriod' => 180,
],
'tx_myextension_my_other_table' => [
'expireField' => 'expire',
],
]);
}
Warning
If your extension overrides the TCA of the scheduler extension, it must be loaded after typo3/cms-scheduler , otherwise the configuration might take no effect.
The first part of the configuration indicates that records older than
180 days should be removed from table tx_
,
based on the timestamp field called "tstamp". The second part
indicates that old records should be removed from table
tx_
directly based on the field expire
which contains expiration dates for each record.
Migration: Supporting custom tables for garbage collection for both TYPO3 13 and 14
If your extension supports both TYPO3 13 (or below) and 14 keep the registration
of additional tables in the extensions ext_
until support
for TYPO3 13 is removed:
<?php
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask;
if ((new Typo3Version())->getMajorVersion() < 14) {
// TODO: Remove once TYPO3 13 support is dropped
// TYPO3 14 configuration can be found in Configuration/TCA/Overrides/tx_scheduler_garbage_collection.php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables']['tx_myextension_errorlog'] = [
'dateField' => 'tstamp',
'expirePeriod' => '180',
];
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][TableGarbageCollectionTask::class]['options']['tables']['tx_myextension_uniqalias'] = [
'expireField' => 'expire',
];
}