From 0d2a39b6654aea5e839cd1f4c9dafa55f00753a3 Mon Sep 17 00:00:00 2001 From: Nicole Cordes <typo3@cordes.co> Date: Tue, 17 Sep 2013 23:23:30 +0200 Subject: [PATCH] [BUGFIX] Install tool uses empty database settings 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 --- .../Action/Step/DatabaseConnect.php | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php b/typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php index 72b1d1ff676c..639e7c567c18 100644 --- a/typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php +++ b/typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php @@ -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 -- GitLab