[TASK] Doctrine: migrate ext:recycler/Tables 30/47730/4
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 16 Apr 2016 14:47:45 +0000 (16:47 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Mon, 18 Apr 2016 16:11:40 +0000 (18:11 +0200)
Resolves: #75713
Releases: master
Change-Id: Ia82c7055e71ec154264f6b658addf49c5f9187a5
Reviewed-on: https://review.typo3.org/47730
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/recycler/Classes/Domain/Model/Tables.php

index cba3abf..e067013 100644 (file)
@@ -15,6 +15,8 @@ namespace TYPO3\CMS\Recycler\Domain\Model;
  */
 
 use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Database\Connection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Recycler\Utility\RecyclerUtility;
 
 /**
@@ -34,11 +36,23 @@ class Tables
         $deletedRecordsTotal = 0;
         $lang = $this->getLanguageService();
         $tables = array();
+        $connection = GeneralUtility::makeInstance(ConnectionPool::class);
         foreach (RecyclerUtility::getModifyableTables() as $tableName) {
             $deletedField = RecyclerUtility::getDeletedField($tableName);
             if ($deletedField) {
                 // Determine whether the table has deleted records:
-                $deletedCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', $tableName, $deletedField . '<>0');
+                $queryBuilder = $connection->getQueryBuilderForTable($tableName);
+                $queryBuilder
+                    ->getQueryContext()
+                    ->setIgnoreEnableFields(true)
+                    ->setIncludeDeleted(true);
+
+                $deletedCount = $queryBuilder->count('uid')
+                    ->from($tableName)
+                    ->where($queryBuilder->expr()->neq($deletedField, 0))
+                    ->execute()
+                    ->fetchColumn();
+
                 if ($deletedCount) {
                     /* @var $deletedDataObject DeletedRecords */
                     $deletedDataObject = GeneralUtility::makeInstance(DeletedRecords::class);
@@ -66,16 +80,6 @@ class Tables
     }
 
     /**
-     * Returns an instance of DatabaseConnection
-     *
-     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * Returns an instance of LanguageService
      *
      * @return \TYPO3\CMS\Lang\LanguageService