[TASK] Doctrine: Migrate additional parts of BackendUtility 51/49251/5
authorWouter Wolters <typo3@wouterwolters.nl>
Thu, 28 Jul 2016 13:22:36 +0000 (15:22 +0200)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Wed, 3 Aug 2016 15:01:26 +0000 (17:01 +0200)
Resolves: #77290
Releases: master
Change-Id: I5c7ea758658107c2cf80c59961d3137a91c80443
Reviewed-on: https://review.typo3.org/49251
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
typo3/sysext/backend/Classes/Utility/BackendUtility.php
typo3/sysext/core/Tests/Unit/Authentication/BackendUserAuthenticationTest.php

index 95d66d6..4b0420a 100644 (file)
@@ -3660,10 +3660,10 @@ class BackendUtility
     {
         $beUser = static::getBackendUserAuthentication();
         if (isset($beUser->user['uid'])) {
-            $user_id = (int)$beUser->user['uid'];
+            $userId = (int)$beUser->user['uid'];
             if ($table && $uid) {
-                $fields_values = array(
-                    'userid' => $user_id,
+                $fieldsValues = array(
+                    'userid' => $userId,
                     'feuserid' => 0,
                     'tstamp' => $GLOBALS['EXEC_TIME'],
                     'record_table' => $table,
@@ -3671,9 +3671,19 @@ class BackendUtility
                     'username' => $beUser->user['username'],
                     'record_pid' => $pid
                 );
-                static::getDatabaseConnection()->exec_INSERTquery('sys_lockedrecords', $fields_values);
+                GeneralUtility::makeInstance(ConnectionPool::class)
+                    ->getConnectionForTable('sys_lockedrecords')
+                    ->insert(
+                        'sys_lockedrecords',
+                        $fieldsValues
+                    );
             } else {
-                static::getDatabaseConnection()->exec_DELETEquery('sys_lockedrecords', 'userid=' . (int)$user_id);
+                GeneralUtility::makeInstance(ConnectionPool::class)
+                    ->getConnectionForTable('sys_lockedrecords')
+                    ->delete(
+                        'sys_lockedrecords',
+                        ['userid' => (int)$userId]
+                    );
             }
         }
     }
index 5f5f741..c77eead 100644 (file)
@@ -76,6 +76,16 @@ class BackendUserAuthenticationTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     {
         /** @var ObjectProphecy|Connection $connection */
         $connection = $this->prophesize(Connection::class);
+        $connection->delete('sys_lockedrecords', Argument::cetera())->willReturn(1);
+
+        /** @var ObjectProphecy|ConnectionPool $connectionPool */
+        $connectionPool = $this->prophesize(ConnectionPool::class);
+        $connectionPool->getConnectionForTable(Argument::cetera())->willReturn($connection->reveal());
+
+        GeneralUtility::addInstance(ConnectionPool::class, $connectionPool->reveal());
+
+        /** @var ObjectProphecy|Connection $connection */
+        $connection = $this->prophesize(Connection::class);
         $connection->delete('be_sessions', Argument::cetera())->willReturn(1);
 
         /** @var ObjectProphecy|ConnectionPool $connectionPool */