[TASK] Doctrine: migrate $GLOBALS['TYPO3_DB']->exec_TRUNCATEquery 55/47955/4
authorFrank Naegler <frank.naegler@typo3.org>
Thu, 28 Apr 2016 13:05:57 +0000 (15:05 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 29 Apr 2016 07:36:36 +0000 (09:36 +0200)
Resolves: #75969
Releases: master
Change-Id: Ie82b68c6efcbb9b4c4304de1323269decb091376
Reviewed-on: https://review.typo3.org/47955
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php
typo3/sysext/core/Classes/DataHandling/DataHandler.php
typo3/sysext/core/Classes/Resource/ProcessedFileRepository.php
typo3/sysext/extensionmanager/Classes/Utility/Repository/Helper.php
typo3/sysext/install/Classes/Controller/Action/Tool/CleanUp.php
typo3/sysext/install/Classes/Service/ClearCacheService.php

index aedce8d..eea0ba5 100644 (file)
@@ -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);
     }
 
     /**
index 34cf327..ccba87f 100644 (file)
@@ -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();
                 }
index f74ca9a..b23c0f3 100644 (file)
@@ -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;
     }
index 6e998b0..ab38440 100644 (file)
@@ -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'];
-    }
 }
index 815317c..4f962b5 100644 (file)
@@ -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;
                 }
             }
index bec5761..4513bfb 100644 (file)
@@ -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');
             }
         }