16 use Doctrine\DBAL\DBALException;
55 $tableConfigurations =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'scheduler'][
'tasks'][self::class][
'options'][
'tables'];
56 $tableHandled =
false;
57 foreach ($tableConfigurations as $tableName => $configuration) {
58 if ($this->allTables || $tableName === $this->table) {
64 throw new \RuntimeException(self::class .
' misconfiguration: ' . $this->table .
' does not exist in configuration', 1308354399);
79 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
$table);
81 if (!empty($configuration[
'expireField'])) {
82 $field = $configuration[
'expireField'];
87 $queryBuilder->expr()->lte($field, $queryBuilder->createNamedParameter($dateLimit, \PDO::PARAM_INT)),
88 $queryBuilder->expr()->gt($field, $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT))
90 } elseif (!empty($configuration[
'dateField'])) {
91 if (!$this->allTables) {
92 $deleteTimestamp = strtotime(
'-' . $this->numberOfDays .
'days');
94 if (!isset($configuration[
'expirePeriod'])) {
95 throw new \RuntimeException(self::class .
' misconfiguration: No expirePeriod defined for table ' .
$table, 1308355095);
97 $deleteTimestamp = strtotime(
'-' . $configuration[
'expirePeriod'] .
'days');
100 $queryBuilder->expr()->lt(
101 $configuration[
'dateField'],
102 $queryBuilder->createNamedParameter($deleteTimestamp, \PDO::PARAM_INT)
106 throw new \RuntimeException(self::class .
' misconfiguration: Either expireField or dateField must be defined for table ' .
$table, 1308355268);
110 $queryBuilder->execute();
111 }
catch (DBALException $e) {
112 throw new \RuntimeException(self::class .
' failed for table ' . $this->table .
' with error: ' . $e->getMessage(), 1308255491);
124 if ($this->allTables) {
125 $message =
$GLOBALS[
'LANG']->sL(
'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.tableGarbageCollection.additionalInformationAllTables');
127 $message = sprintf(
$GLOBALS[
'LANG']->sL(
'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:label.tableGarbageCollection.additionalInformationTable'), $this->table);