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