[TASK] Doctrine: Migrate last exec_SELECT_mm_query() 59/49559/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Tue, 23 Aug 2016 16:12:15 +0000 (18:12 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 23 Aug 2016 18:53:34 +0000 (20:53 +0200)
Change-Id: I0df6dc1fd58f52d106755c8bbd8df039c80fb960
Resolves: #77611
Releases: master
Reviewed-on: https://review.typo3.org/49559
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Collection/StaticRecordCollection.php

index 1821c4d..13d3bf4 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Core\Collection;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+
 /**
  * Implementation of a RecordCollection for static TCA-Records
  */
@@ -30,7 +33,7 @@ class StaticRecordCollection extends AbstractRecordCollection implements Editabl
     public static function create(array $collectionRecord, $fillItems = false)
     {
         /** @var $collection StaticRecordCollection */
-        $collection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
+        $collection = GeneralUtility::makeInstance(
             StaticRecordCollection::class,
             $collectionRecord['table_name']
         );
@@ -162,19 +165,35 @@ class StaticRecordCollection extends AbstractRecordCollection implements Editabl
      */
     protected function getCollectedRecords()
     {
+        $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::$storageTableName);
+        $queryBuilder->getRestrictions()->removeAll();
+        $statement = $queryBuilder->select($this->getItemTableName() . '.*')
+            ->from(self::$storageTableName)
+            ->join(
+                self::$storageTableName,
+                'sys_collection_entries',
+                'sys_collection_entries_join',
+                $queryBuilder->expr()->eq(
+                    'sys_collection_entries_join.uid_local',
+                    $queryBuilder->quoteIdentifier(self::$storageTableName . '.uid')
+                )
+            )
+            ->join(
+                'sys_collection_entries_join',
+                $this->getItemTableName(),
+                $this->getItemTableName() . '_join',
+                $queryBuilder->expr()->eq(
+                    'sys_collection_entries_join.uid_local',
+                    $queryBuilder->quoteIdentifier($this->getItemTableName() . '_join.uid')
+                )
+            )
+            ->where(
+                $queryBuilder->expr()->eq(self::$storageTableName . '.uid', (int)$this->getIdentifier())
+            )
+            ->execute();
         $relatedRecords = array();
-        $resource = $this->getDatabaseConnection()->exec_SELECT_mm_query(
-            $this->getItemTableName() . '.*',
-            self::$storageTableName,
-            'sys_collection_entries',
-            $this->getItemTableName(),
-            'AND ' . self::$storageTableName . '.uid=' . (int)$this->getIdentifier()
-        );
-        if ($resource) {
-            while ($record = $this->getDatabaseConnection()->sql_fetch_assoc($resource)) {
-                $relatedRecords[] = $record;
-            }
-            $this->getDatabaseConnection()->sql_free_result($resource);
+        while ($record = $statement->fetch()) {
+            $relatedRecords[] = $record;
         }
         return $relatedRecords;
     }