[BUGFIX] Install tool uses empty database settings 66/23866/4
authorNicole Cordes <typo3@cordes.co>
Tue, 17 Sep 2013 21:23:30 +0000 (23:23 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Thu, 26 Sep 2013 21:00:04 +0000 (23:00 +0200)
Some systems allow to connect with empty username / password
configuration to the database. Although this is not wrong the install
tool should always ask for database credentials for new installations.
This patch prevents the install tool from setting an empty username and
password as default values without manually submitting the form.

Resolves: #51540
Resolves: #51956
Releases: 6.2
Change-Id: Ic245635bf649f4ad477d793eda658096ed659aa0
Reviewed-on: https://review.typo3.org/23866
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php

index 72b1d1f..639e7c5 100644 (file)
@@ -208,7 +208,7 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
                if ($this->isConnectSuccessful() && $this->isConfigurationComplete()) {
                        return FALSE;
                }
-               if (!$this->isConfigurationComplete() && !$this->isDbalEnabled()) {
+               if (!$this->isHostConfigured() && !$this->isDbalEnabled()) {
                        $this->useDefaultValuesForNotConfiguredOptions();
                        throw new \TYPO3\CMS\Install\Controller\Exception\RedirectException(
                                'Wrote default settings to LocalConfiguration.php, redirect needed',
@@ -319,21 +319,33 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
         * Check LocalConfiguration.php for required database settings:
         * - 'host' is mandatory and must not be empty
         * - 'port' OR 'socket' is mandatory, but may be empty
-        * - 'username' and 'password' are mandatory, but may be empty
         *
-        * @return boolean TRUE if required settings are present
+        * @return boolean TRUE if host is set
         */
-       protected function isConfigurationComplete() {
-               $configurationComplete = TRUE;
+       protected function isHostConfigured() {
+               $hostConfigured = TRUE;
                if (empty($GLOBALS['TYPO3_CONF_VARS']['DB']['host'])) {
-                       $configurationComplete = FALSE;
+                       $hostConfigured = FALSE;
                }
                if (
                        !isset($GLOBALS['TYPO3_CONF_VARS']['DB']['port'])
                        && !isset($GLOBALS['TYPO3_CONF_VARS']['DB']['socket'])
                ) {
-                       $configurationComplete = FALSE;
+                       $hostConfigured = FALSE;
                }
+               return $hostConfigured;
+       }
+
+       /**
+        * Check LocalConfiguration.php for required database settings:
+        * - 'host' is mandatory and must not be empty
+        * - 'port' OR 'socket' is mandatory, but may be empty
+        * - 'username' and 'password' are mandatory, but may be empty
+        *
+        * @return boolean TRUE if required settings are present
+        */
+       protected function isConfigurationComplete() {
+               $configurationComplete = $this->isHostConfigured();
                if (!isset($GLOBALS['TYPO3_CONF_VARS']['DB']['username'])) {
                        $configurationComplete = FALSE;
                }
@@ -362,10 +374,6 @@ class DatabaseConnect extends Action\AbstractAction implements StepInterface {
        protected function useDefaultValuesForNotConfiguredOptions() {
                $localConfigurationPathValuePairs = array();
 
-               // Mandatory settings will always be written to LocalConfiguration.php, username/password may be empty
-               $localConfigurationPathValuePairs['DB/username'] = $this->getConfiguredUsername();
-               $localConfigurationPathValuePairs['DB/password'] = $this->getConfiguredPassword();
-
                $localConfigurationPathValuePairs['DB/host'] = $this->getConfiguredHost();
 
                // If host is "local" either by upgrading or by first install, we try a socket