[BUGFIX] DBAL: Incomplete database configuration 45/28045/6
authorXavier Perseguers <xavier@typo3.org>
Tue, 11 Mar 2014 15:08:26 +0000 (16:08 +0100)
committerMarkus Klein <klein.t3@mfc-linz.at>
Tue, 11 Mar 2014 17:25:14 +0000 (18:25 +0100)
When no database connection is established, handler_init() is used. But
at this point, the credentials are unkown and the method returns void.

As all parameters of method sql_pconnect() are deprecated, move the
_DEFAULT initialization into method handler_init() to get credentials
into the DBAL configuration.

Resolves: #56257
Releases: 6.2
Change-Id: Ifd908fab1382434d376a9358d0ae9c3af083616e
Reviewed-on: https://review.typo3.org/28045
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Andreas Fernandez
Tested-by: Andreas Fernandez
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php

index 4066130..6097077 100644 (file)
@@ -2550,12 +2550,6 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                        $this->handleDeprecatedConnectArguments($host, $username, $password);
                }
 
-               // Overriding the _DEFAULT handler configuration of username, password, localhost and database name:
-               $this->handlerCfg['_DEFAULT']['config']['username'] = $this->databaseUsername;
-               $this->handlerCfg['_DEFAULT']['config']['password'] = $this->databaseUserPassword;
-               $this->handlerCfg['_DEFAULT']['config']['host'] = $this->databaseHost;
-               $this->handlerCfg['_DEFAULT']['config']['port'] = (int)$this->databasePort;
-               $this->handlerCfg['_DEFAULT']['config']['database'] = $this->databaseName;
                // Initializing and output value:
                $sqlResult = $this->handler_init('_DEFAULT');
                return $sqlResult;
@@ -3021,6 +3015,14 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                if (!isset($this->handlerCfg[$handlerKey]) || !is_array($this->handlerCfg[$handlerKey])) {
                        throw new \RuntimeException('ERROR: No handler for key "' . $handlerKey . '"', 1310028018);
                }
+               if ($handlerKey === '_DEFAULT') {
+                       // Overriding the _DEFAULT handler configuration of username, password, localhost and database name:
+                       $this->handlerCfg[$handlerKey]['config']['username'] = $this->databaseUsername;
+                       $this->handlerCfg[$handlerKey]['config']['password'] = $this->databaseUserPassword;
+                       $this->handlerCfg[$handlerKey]['config']['host'] = $this->databaseHost;
+                       $this->handlerCfg[$handlerKey]['config']['port'] = (int)$this->databasePort;
+                       $this->handlerCfg[$handlerKey]['config']['database'] = $this->databaseName;
+               }
                $cfgArray = $this->handlerCfg[$handlerKey];
                if (!$cfgArray['config']['database']) {
                        // Configuration is incomplete