[TASK] Doctrine: Replace occurrences of exec_INSERTmultipleRows 64/47764/5
authorMathias Schreiber <mathias.schreiber@wmdb.de>
Mon, 18 Apr 2016 20:55:16 +0000 (22:55 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 19 Apr 2016 09:35:53 +0000 (11:35 +0200)
Resolves: #75758
Releases: master
Change-Id: I9ef426583b6c24369446c7736931ef3beb6b7b6f
Reviewed-on: https://review.typo3.org/47764
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php
typo3/sysext/core/Tests/Unit/Cache/Backend/Typo3DatabaseBackendTest.php
typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php
typo3/sysext/indexed_search/Classes/Indexer.php

index f6d9df2..aedce8d 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\Core\Cache\Backend;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * A caching backend which stores cache entries in database tables
@@ -157,7 +159,9 @@ class Typo3DatabaseBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend
                 $tagRow[] = $tag;
                 $tagRows[] = $tagRow;
             }
-            $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows($this->tagsTable, $fields, $tagRows);
+            GeneralUtility::makeInstance(ConnectionPool::class)
+                ->getConnectionForTable($this->tagsTable)
+                ->bulkInsert($this->tagsTable, $tagRows, $fields);
         }
     }
 
index 4ce6d11..80b5318 100644 (file)
@@ -13,6 +13,9 @@ namespace TYPO3\CMS\Core\Tests\Unit\Cache\Backend;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Database\Connection;
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Test case
@@ -130,27 +133,28 @@ class Typo3DatabaseBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $backend = $this->getMock(\TYPO3\CMS\Core\Cache\Backend\Typo3DatabaseBackend::class, array('dummy'), array('Testing'));
         $this->setUpMockFrontendOfBackend($backend);
         $GLOBALS['TYPO3_DB'] = $this->getMock(\TYPO3\CMS\Core\Database\DatabaseConnection::class, array(), array(), '', false);
-        $GLOBALS['TYPO3_DB']
-            ->expects($this->once())
-            ->method('exec_INSERTmultipleRows')
-            ->with(
-                'cf_Testing_tags',
-                $this->callback(function (array $data) {
-                    if ($data[0] === 'identifier' && $data[1] === 'tag') {
-                        return true;
-                    }
+        $connectionPool = $this->getMock(ConnectionPool::class);
+        $connection = $this->getMock(Connection::class, array(), array(), '', false);
+        $connectionPool->expects($this->once())->method('getConnectionForTable')->willReturn($connection);
+        $connection->expects($this->once())->method('bulkInsert')->with(
+            'cf_Testing_tags',
+            $this->callback(function (array $data) {
+                if ($data[0][0] !== 'anIdentifier' || $data[0][1] !== 'UnitTestTag%tag1') {
                     return false;
-                }),
-                $this->callback(function (array $data) {
-                    if ($data[0][0] !== 'anIdentifier' || $data[0][1] !== 'UnitTestTag%tag1') {
-                        return false;
-                    }
-                    if ($data[1][0] !== 'anIdentifier' || $data[1][1] !== 'UnitTestTag%tag2') {
-                        return false;
-                    }
+                }
+                if ($data[1][0] !== 'anIdentifier' || $data[1][1] !== 'UnitTestTag%tag2') {
+                    return false;
+                }
+                return true;
+            }),
+            $this->callback(function (array $data) {
+                if ($data[0] === 'identifier' && $data[1] === 'tag') {
                     return true;
-                })
-            );
+                }
+                return false;
+            })
+        );
+        GeneralUtility::addInstance(ConnectionPool::class, $connectionPool);
         $backend->set('anIdentifier', 'someData', array('UnitTestTag%tag1', 'UnitTestTag%tag2'));
     }
 
@@ -182,7 +186,7 @@ class Typo3DatabaseBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                     }
                     return false;
                 }
-            ));
+                ));
 
         $backend->set('anIdentifier', 'someData');
     }
@@ -209,7 +213,7 @@ class Typo3DatabaseBackendTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
                     }
                     return false;
                 }
-            ));
+                ));
 
         $backend->set('aIdentifier', 'someData', array(), 0);
     }
index 136360c..f653712 100644 (file)
@@ -13,6 +13,8 @@ namespace TYPO3\CMS\Extensionmanager\Utility\Importer;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Database\ConnectionPool;
+use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
  * Importer object for extension list
@@ -139,7 +141,13 @@ class ExtensionListUtility implements \SplObserver
         $this->parser->parseXml($zlibStream . $localExtensionListFile);
         // flush last rows to database if existing
         if (!empty($this->arrRows)) {
-            $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('tx_extensionmanager_domain_model_extension', self::$fieldNames, $this->arrRows, self::$fieldIndicesNoQuote);
+            GeneralUtility::makeInstance(ConnectionPool::class)
+                ->getConnectionForTable('tx_extensionmanager_domain_model_extension')
+                ->bulkInsert(
+                    'tx_extensionmanager_domain_model_extension',
+                    $this->arrRows,
+                    self::$fieldNames
+                );
         }
         $extensions = $this->extensionRepository->insertLastVersion($this->repositoryUid);
         $this->repositoryRepository->updateRepositoryCount($extensions, $this->repositoryUid);
@@ -156,7 +164,13 @@ class ExtensionListUtility implements \SplObserver
     {
         // flush every 50 rows to database
         if ($this->sumRecords !== 0 && $this->sumRecords % 50 === 0) {
-            $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('tx_extensionmanager_domain_model_extension', self::$fieldNames, $this->arrRows, self::$fieldIndicesNoQuote);
+            GeneralUtility::makeInstance(ConnectionPool::class)
+                ->getConnectionForTable('tx_extensionmanager_domain_model_extension')
+                ->bulkInsert(
+                    'tx_extensionmanager_domain_model_extension',
+                    $this->arrRows,
+                    self::$fieldNames
+                );
             $this->arrRows = array();
         }
         $versionRepresentations = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionStringToArray($subject->getVersion());
index 18f0431..e4b0928 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\IndexedSearch;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Core\Utility\MathUtility;
@@ -2016,7 +2017,9 @@ class Indexer
                     $val['cmp'] & $this->flagBitMask
                 );
             }
-            $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('index_rel', $fields, $rows);
+            GeneralUtility::makeInstance(ConnectionPool::class)
+                ->getConnectionForTable('index_rel')
+                ->bulkInsert('index_rel', $rows, $fields);
         }
     }