‪TYPO3CMS  10.4
OptimizeDatabaseTableTask.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Doctrine\DBAL\DBALException;
21 
31 {
38  public ‪$selectedTables = [];
39 
45  public function ‪execute()
46  {
47  $connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
48  foreach ($this->selectedTables as $tableName) {
49  $connection = $connectionPool->getConnectionForTable($tableName);
50 
51  if (strpos($connection->getServerVersion(), 'MySQL') === 0) {
52  try {
53  $connection->query('OPTIMIZE TABLE ' . $connection->quoteIdentifier($tableName));
54  } catch (DBALException $e) {
55  throw new \RuntimeException(
56  TableGarbageCollectionTask::class . ' failed for: ' . $tableName . ': ' .
57  $e->getPrevious()->getMessage(),
58  1441390263
59  );
60  }
61  }
62  }
63 
64  return true;
65  }
66 
72  public function ‪getAdditionalInformation()
73  {
74  return implode(', ', $this->selectedTables);
75  }
76 }
‪TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask\execute
‪bool execute()
Definition: OptimizeDatabaseTableTask.php:44
‪TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask\getAdditionalInformation
‪string getAdditionalInformation()
Definition: OptimizeDatabaseTableTask.php:71
‪TYPO3\CMS\Scheduler\Task
Definition: AbstractTask.php:16
‪TYPO3\CMS\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:35
‪TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask
Definition: OptimizeDatabaseTableTask.php:31
‪TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableTask\$selectedTables
‪array $selectedTables
Definition: OptimizeDatabaseTableTask.php:37
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46