diff --git a/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php b/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php index f6d9df283ecbfaa4c957163226b27e1595fd5709..aedce8d1928f3d64a15f85d152195e77d994f266 100644 --- a/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php +++ b/typo3/sysext/core/Classes/Cache/Backend/Typo3DatabaseBackend.php @@ -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); } } diff --git a/typo3/sysext/core/Tests/Unit/Cache/Backend/Typo3DatabaseBackendTest.php b/typo3/sysext/core/Tests/Unit/Cache/Backend/Typo3DatabaseBackendTest.php index 4ce6d1100e5952b8abdc03e12b41f28e12cdbf9a..80b5318c53f8a7f418f0a21e4ee5b21ad3d44a9f 100644 --- a/typo3/sysext/core/Tests/Unit/Cache/Backend/Typo3DatabaseBackendTest.php +++ b/typo3/sysext/core/Tests/Unit/Cache/Backend/Typo3DatabaseBackendTest.php @@ -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); } diff --git a/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php b/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php index 136360c084d9aee122cca17249bf8a5de25bcffd..f653712f7c74ad8695319aa01955afa743d8d549 100644 --- a/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php +++ b/typo3/sysext/extensionmanager/Classes/Utility/Importer/ExtensionListUtility.php @@ -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()); diff --git a/typo3/sysext/indexed_search/Classes/Indexer.php b/typo3/sysext/indexed_search/Classes/Indexer.php index 18f043190c3dd68735aaf283e368629bfedf3ec8..e4b09284df7858e3c5bd4e997e5e3ff4eff1e332 100644 --- a/typo3/sysext/indexed_search/Classes/Indexer.php +++ b/typo3/sysext/indexed_search/Classes/Indexer.php @@ -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); } }