Commit d3d23b47 authored by Frank Nägler's avatar Frank Nägler Committed by Morton Jonuschat
Browse files

[TASK] Doctrine: migrate $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery

Resolves: #75969
Releases: master
Change-Id: Ie82b68c6efcbb9b4c4304de1323269decb091376
Reviewed-on: https://review.typo3.org/47955


Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarMarkus Sommer <markussom@posteo.de>
Reviewed-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: default avatarMorton Jonuschat <m.jonuschat@mojocode.de>
parent a51a5d66
......@@ -265,8 +265,12 @@ class Typo3DatabaseBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
public function flush()
{
$this->throwExceptionIfFrontendDoesNotExist();
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery($this->cacheTable);
$GLOBALS['TYPO3_DB']->exec_TRUNCATEquery($this->tagsTable);
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($this->cacheTable)
->truncate($this->cacheTable);
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($this->tagsTable)
->truncate($this->tagsTable);
}
/**
......
......@@ -20,6 +20,7 @@ use TYPO3\CMS\Core\Cache\CacheManager;
use TYPO3\CMS\Core\Cache\Frontend\VariableFrontend;
use TYPO3\CMS\Core\Charset\CharsetConverter;
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\DatabaseConnection;
use TYPO3\CMS\Core\Database\ReferenceIndex;
use TYPO3\CMS\Core\Database\RelationHandler;
......@@ -7813,7 +7814,10 @@ class DataHandler
case 'all':
if ($this->admin || $this->BE_USER->getTSConfigVal('options.clearCache.all')) {
$this->getCacheManager()->flushCaches();
$this->databaseConnection->exec_TRUNCATEquery('cache_treelist');
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('cache_treelist')
->truncate('cache_treelist');
// Delete Opcode Cache
GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive();
}
......
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Resource;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Log\LogManager;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -228,7 +229,9 @@ class ProcessedFileRepository extends AbstractRepository
}
}
$this->databaseConnection->exec_TRUNCATEquery($this->table);
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($this->table)
->truncate($this->table);
return $errorCount;
}
......
......@@ -14,6 +14,8 @@ namespace TYPO3\CMS\Extensionmanager\Utility\Repository;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
use TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility;
......@@ -307,7 +309,9 @@ class Helper implements \TYPO3\CMS\Core\SingletonInterface
// Use straight query as extbase "remove" is too slow here
// This truncates the whole table. It would be more correct to remove only rows of a specific
// repository, but multiple repository handling is not implemented, and truncate is quicker.
$this->getDatabaseConnection()->exec_TRUNCATEquery('tx_extensionmanager_domain_model_extension');
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('tx_extensionmanager_domain_model_extension')
->truncate('tx_extensionmanager_domain_model_extension');
}
// no further problems - start of import process
if ($updateNecessity === 0) {
......@@ -320,14 +324,4 @@ class Helper implements \TYPO3\CMS\Core\SingletonInterface
}
return $updated;
}
/**
* Get database connection
*
* @return \TYPO3\CMS\Core\Database\DatabaseConnection
*/
protected function getDatabaseConnection()
{
return $GLOBALS['TYPO3_DB'];
}
}
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Controller\Action\Tool;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Resource\ProcessedFileRepository;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
......@@ -135,11 +136,12 @@ class CleanUp extends Action\AbstractAction
protected function clearSelectedTables()
{
$clearedTables = array();
$database = $this->getDatabaseConnection();
if (isset($this->postValues['values']) && is_array($this->postValues['values'])) {
foreach ($this->postValues['values'] as $tableName => $selected) {
if ($selected == 1) {
$database->exec_TRUNCATEquery($tableName);
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($tableName)
->truncate($tableName);
$clearedTables[] = $tableName;
}
}
......
......@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Install\Service;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
......@@ -53,11 +54,15 @@ class ClearCacheService
foreach ($tables as $table) {
$tableName = $table['Name'];
if (substr($tableName, 0, 3) === 'cf_') {
$database->exec_TRUNCATEquery($tableName);
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable($tableName)
->truncate($tableName);
} elseif ($tableName === 'cache_treelist') {
// cache_treelist is not implemented in the caching framework.
// clear this table manually
$database->exec_TRUNCATEquery('cache_treelist');
GeneralUtility::makeInstance(ConnectionPool::class)
->getConnectionForTable('cache_treelist')
->truncate('cache_treelist');
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment