[BUGFIX] Improve database connection smooth migration wizard 53/24553/4
authorNicole Cordes <typo3@cordes.co>
Fri, 11 Oct 2013 09:02:45 +0000 (11:02 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 17 Oct 2013 19:34:11 +0000 (21:34 +0200)
This patch adds support for local database connections over ips applying
to mask 127.xxx.xxx.xxx as specified in RFC 790. Additionally the
support for non local host connections is improved by setting a default
port independent from host name.

Resolves: #52687
Releases: 6.2
Change-Id: I2ddde8241003b78aee8a196ed4bd5dd78e3d20cb
Reviewed-on: https://review.typo3.org/24553
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Alexander Opitz
Tested-by: Alexander Opitz
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php

index 0ddee17..43dffce 100644 (file)
@@ -379,24 +379,30 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                // If host is "local" either by upgrading or by first install, we try a socket
                // connection first and use TCP/IP as fallback
                if ($localConfigurationPathValuePairs['DB/host'] === 'localhost'
-                       || $localConfigurationPathValuePairs['DB/host'] === '127.0.0.1'
+                       || \TYPO3\CMS\Core\Utility\GeneralUtility::cmpIP($localConfigurationPathValuePairs['DB/host'], '127.*.*.*')
                        || strlen($localConfigurationPathValuePairs['DB/host']) === 0
                ) {
                        if ($this->isConnectionWithUnixDomainSocketPossible()) {
                                $localConfigurationPathValuePairs['DB/host'] = 'localhost';
                                $localConfigurationPathValuePairs['DB/socket'] = $this->getConfiguredSocket();
                        } else {
-                               $localConfigurationPathValuePairs['DB/host'] = '127.0.0.1';
-                               // Preserve port if already configured in LocalConfiguration.php
-                               $port = $this->getConfiguredPort();
-                               if ($port > 0) {
-                                       $localConfigurationPathValuePairs['DB/port'] = $port;
-                               } else {
-                                       $localConfigurationPathValuePairs['DB/port'] = $this->getConfiguredOrDefaultPort();
+                               if (!\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($localConfigurationPathValuePairs['DB/host'], '127.')) {
+                                       $localConfigurationPathValuePairs['DB/host'] = '127.0.0.1';
                                }
                        }
                }
 
+               if (!isset($localConfigurationPathValuePairs['DB/socket'])) {
+                       // Make sure a default port is set if not configured yet
+                       // This is independent from any host configuration
+                       $port = $this->getConfiguredPort();
+                       if ($port > 0) {
+                               $localConfigurationPathValuePairs['DB/port'] = $port;
+                       } else {
+                               $localConfigurationPathValuePairs['DB/port'] = $this->getConfiguredOrDefaultPort();
+                       }
+               }
+
                /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
                $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
                $configurationManager->setLocalConfigurationValuesByPathValuePairs($localConfigurationPathValuePairs);