[BUGFIX] Initialize database connection in ClearCacheService 36/39636/4
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Wed, 20 May 2015 19:06:03 +0000 (21:06 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Mon, 25 May 2015 11:40:48 +0000 (13:40 +0200)
Without calling initialize() on the DatabaseConnection object
the DBAL the resulting connection configuration will default
to the "native" driver type (MySQL) which results in an error
as there is no MySQL server to contact with the given connection
parameters.

Resolves: #67066
Releases: master, 6.2
Change-Id: Id5d70a122dcca806ee1122cecacad0c8aef27547
Reviewed-on: http://review.typo3.org/39636
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php
typo3/sysext/install/Classes/Service/ClearCacheService.php

index ae4b3fc..4c120bc 100644 (file)
@@ -282,7 +282,6 @@ class DatabaseConnect extends AbstractStepAction {
        protected function isConnectSuccessful() {
                /** @var $databaseConnection \TYPO3\CMS\Core\Database\DatabaseConnection */
                $databaseConnection = $this->objectManager->get(\TYPO3\CMS\Core\Database\DatabaseConnection::class);
-               $databaseConnection->initialize();
 
                if ($this->isDbalEnabled()) {
                        // Set additional connect information based on dbal driver. postgres for example needs
@@ -298,11 +297,9 @@ class DatabaseConnect extends AbstractStepAction {
                $databaseConnection->setDatabasePort($this->getConfiguredPort());
                $databaseConnection->setDatabaseSocket($this->getConfiguredSocket());
 
-               $result = FALSE;
-               if (@$databaseConnection->sql_pconnect()) {
-                       $result = TRUE;
-               }
-               return $result;
+               $databaseConnection->initialize();
+
+               return (bool)@$databaseConnection->sql_pconnect();
        }
 
        /**
index 653f56b..455b468 100644 (file)
@@ -110,6 +110,7 @@ class ClearCacheService {
                        $database->setDatabasePort($GLOBALS['TYPO3_CONF_VARS']['DB']['port']);
                        $database->setDatabaseSocket($GLOBALS['TYPO3_CONF_VARS']['DB']['socket']);
                        $database->setDatabaseName($GLOBALS['TYPO3_CONF_VARS']['DB']['database']);
+                       $database->initialize();
                        $database->connectDB();
                }
                return $database;