[TASK] Doctrine: migrate ext:reports 21/48521/6
authorXavier Ley <xavierley@gmail.com>
Wed, 8 Jun 2016 18:33:18 +0000 (20:33 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 9 Jun 2016 09:52:42 +0000 (11:52 +0200)
Resolves: #76534
Releases: master

Change-Id: I59835fd627f63ae40462ae5f2820cdc730224193
Reviewed-on: https://review.typo3.org/48521
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/reports/Classes/Report/Status/ConfigurationStatus.php
typo3/sysext/reports/Classes/Report/Status/FalStatus.php
typo3/sysext/reports/Classes/Report/Status/SecurityStatus.php

index 0815a42..3800943 100644 (file)
@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Reports\Report\Status;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Messaging\FlashMessageService;
@@ -79,7 +80,14 @@ class ConfigurationStatus implements StatusProviderInterface
         $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
         $severity = ReportStatus::OK;
-        $count = $this->getDatabaseConnection()->exec_SELECTcountRows('*', 'sys_refindex');
+
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_refindex');
+        $count = $queryBuilder
+            ->count('*')
+            ->from('sys_refindex')
+            ->execute()
+            ->fetchColumn(0);
+
         $registry = GeneralUtility::makeInstance(Registry::class);
         $lastRefIndexUpdate = $registry->get('core', 'sys_refindex_lastUpdate');
         if (!$count && $lastRefIndexUpdate) {
index 4a78086..0bf8e83 100644 (file)
@@ -14,7 +14,7 @@ namespace TYPO3\CMS\Reports\Report\Status;
  * The TYPO3 project - inspiring people to share!
  */
 
-use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Resource\StorageRepository;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Lang\LanguageService;
@@ -67,25 +67,34 @@ class FalStatus implements StatusProviderInterface
         }
 
         if (!empty($storages)) {
-            $count = $this->getDatabaseConnection()->exec_SELECTcountRows(
-                '*',
-                'sys_file',
-                'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')'
-            );
+            $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_file');
+
+            $count = $queryBuilder
+                ->count('*')
+                ->from('sys_file')
+                ->where(
+                    $queryBuilder->expr()->eq('missing', 1),
+                    $queryBuilder->expr()->in('storage', array_keys($storages))
+                )
+                ->execute()
+                ->fetchColumn(0);
         }
 
         if ($count) {
             $value = sprintf($this->getLanguageService()->getLL('status_missingFilesCount'), $count);
             $severity = ReportStatus::WARNING;
 
-            $files = $this->getDatabaseConnection()->exec_SELECTgetRows(
-                'identifier,storage',
-                'sys_file',
-                'missing=1 AND storage IN (' . implode(',', array_keys($storages)) . ')',
-                '',
-                '',
-                $maxFilesToShow
-            );
+            $queryBuilder->resetQueryParts();
+            $files = $queryBuilder
+                ->select('identifier', 'storage')
+                ->from('sys_file')
+                ->where(
+                    $queryBuilder->expr()->eq('missing', 1),
+                    $queryBuilder->expr()->in('storage', array_keys($storages))
+                )
+                ->setMaxResults($maxFilesToShow)
+                ->execute()
+                ->fetchAll();
 
             $message = '<p>' . $this->getLanguageService()->getLL('status_missingFilesMessage') . '</p>';
             foreach ($files as $file) {
@@ -107,12 +116,4 @@ class FalStatus implements StatusProviderInterface
     {
         return $GLOBALS['LANG'];
     }
-
-    /**
-     * @return DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }
index cf6fd96..d23ad43 100644 (file)
@@ -15,7 +15,8 @@ namespace TYPO3\CMS\Reports\Report\Status;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\TypoScript\ConfigurationForm;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
@@ -77,10 +78,24 @@ class SecurityStatus implements StatusProviderInterface
         $value = $this->getLanguageService()->getLL('status_ok');
         $message = '';
         $severity = ReportStatus::OK;
-        $whereClause = 'username = ' . $this->getDatabaseConnection()->fullQuoteStr('admin', 'be_users') .
-            BackendUtility::deleteClause('be_users');
-        $res = $this->getDatabaseConnection()->exec_SELECTquery('uid, username, password', 'be_users', $whereClause);
-        $row = $this->getDatabaseConnection()->sql_fetch_assoc($res);
+
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
+        $queryBuilder->getRestrictions()
+            ->removeAll()
+            ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
+
+        $row = $queryBuilder
+            ->select('uid', 'username', 'password')
+            ->from('be_users')
+            ->where(
+                $queryBuilder->expr()->eq(
+                    'username',
+                    $queryBuilder->quote('admin')
+                )
+            )
+            ->execute()
+            ->fetch();
+
         if (!empty($row)) {
             $secure = true;
             /** @var \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface $saltingObject */
@@ -111,7 +126,6 @@ class SecurityStatus implements StatusProviderInterface
                 );
             }
         }
-        $this->getDatabaseConnection()->sql_free_result($res);
         return GeneralUtility::makeInstance(ReportStatus::class, $this->getLanguageService()->getLL('status_adminUserAccount'), $value, $message, $severity);
     }
 
@@ -235,12 +249,4 @@ class SecurityStatus implements StatusProviderInterface
     {
         return $GLOBALS['LANG'];
     }
-
-    /**
-     * @return DatabaseConnection
-     */
-    protected function getDatabaseConnection()
-    {
-        return $GLOBALS['TYPO3_DB'];
-    }
 }