[TASK] Doctrine: Migrate EXT:sys_note 68/47768/3
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 19 Apr 2016 05:33:39 +0000 (07:33 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 19 Apr 2016 13:43:12 +0000 (15:43 +0200)
Migrate all database calls of EXT:sys_note to doctrine

Resolves: #75765
Releases: master
Change-Id: Ieb8bf69f7898de204d4f788afb0cf1f9c0945253
Reviewed-on: https://review.typo3.org/47768
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Michiel Roos <michiel@maxserv.com>
Tested-by: Michiel Roos <michiel@maxserv.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/sys_note/Classes/Core/Bootstrap.php

index d443ca2..cb76d08 100644 (file)
@@ -15,7 +15,8 @@ namespace TYPO3\CMS\SysNote\Core;
  */
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
-use TYPO3\CMS\Core\Database\DatabaseConnection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Database\Query\QueryBuilder;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -39,19 +40,6 @@ class Bootstrap
     protected $currentGetArguments;
 
     /**
-     * @var DatabaseConnection
-     */
-    protected $databaseConnection;
-
-    /**
-     * @param DatabaseConnection $databaseConnection
-     */
-    public function __construct(DatabaseConnection $databaseConnection = null)
-    {
-        $this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB'];
-    }
-
-    /**
      * Bootstrap extbase and execute controller
      *
      * @param string $controllerName Controller to execute
@@ -88,12 +76,19 @@ class Bootstrap
         if (!isset($arguments['pids']) || empty($arguments['pids']) || empty($GLOBALS['BE_USER']->user['uid'])) {
             return false;
         }
-        $pidList = $this->databaseConnection->cleanIntList($arguments['pids']);
+        $pidList = GeneralUtility::intExplode(',', $arguments['pids'], true);
         if (empty($pidList)) {
             return false;
         }
-        // check if there are records
-        return ($this->databaseConnection->exec_SELECTcountRows('*', 'sys_note', 'pid IN (' . $pidList . ')' . BackendUtility::deleteClause('sys_note')) > 0);
+        /** @var QueryBuilder $queryBuilder */
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_note');
+        $count = $queryBuilder
+            ->count('uid')
+            ->from('sys_note')
+            ->where($queryBuilder->expr()->in('pid', $pidList))
+            ->execute()
+            ->fetchColumn();
+        return (bool)$count;
     }
 
     /**