[TASK] Doctrine: Migrate part of install tool class DatabaseData 76/49276/2
authorMarkus Hoelzle <typo3@markus-hoelzle.de>
Mon, 1 Aug 2016 10:50:51 +0000 (12:50 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 1 Aug 2016 16:02:05 +0000 (18:02 +0200)
Doctrine: Migrate function "execute()" of install tool class DatabaseData

Resolves: #77324
Releases: master
Change-Id: Ie2b5c8092e01b163540f3cacc824434fba34b8e3
Reviewed-on: https://review.typo3.org/49276
Tested-by: Bamboo TYPO3com <info@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/install/Classes/Controller/Action/Step/DatabaseData.php

index 7aa6332..da7e999 100644 (file)
@@ -14,7 +14,9 @@ namespace TYPO3\CMS\Install\Controller\Action\Step;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Doctrine\DBAL\DBALException;
 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
+use TYPO3\CMS\Core\Database\ConnectionPool;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Install\Status\ErrorStatus;
 
@@ -70,16 +72,20 @@ class DatabaseData extends AbstractStepAction
             'tstamp' => $GLOBALS['EXEC_TIME'],
             'crdate' => $GLOBALS['EXEC_TIME']
         );
-        if (false === $this->getDatabaseConnection()->exec_INSERTquery('be_users', $adminUserFields)) {
+        $databaseConnection = GeneralUtility::makeInstance(ConnectionPool::class)
+            ->getConnectionForTable('be_users');
+        try {
+            $databaseConnection->insert('be_users', $adminUserFields);
+        } catch (DBALException $exception) {
             $errorStatus = GeneralUtility::makeInstance(ErrorStatus::class);
             $errorStatus->setTitle('Administrator account not created!');
             $errorStatus->setMessage(
                 'The administrator account could not be created. The following error occurred:' . LF .
-                $this->getDatabaseConnection()->sql_error()
+                $exception->getPrevious()->getMessage()
             );
             $result[] = $errorStatus;
             return $result;
-        };
+        }
 
         // Set password as install tool password
         $configurationManager->setLocalConfigurationValueByPath('BE/installToolPassword', $this->getHashedPassword($password));