[TASK] Show actual connect problem in Install tool 48/51948/9
authorThomas Hohn <thomas@hohn.dk>
Sat, 4 Mar 2017 07:16:25 +0000 (08:16 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Mon, 6 Mar 2017 13:47:04 +0000 (14:47 +0100)
If a connection can't be established to the database show the
actual exception message instead of just asking the user to check.
Can be due to faulty configuration in LocalConfiguration.php

Resolves: #80134
Releases: master
Change-Id: Ib04f4ac74ca8234dd18d5bc9ba71c4d75c28038f
Reviewed-on: https://review.typo3.org/51948
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/install/Classes/Controller/Action/Step/DatabaseConnect.php

index 5fabed1..7501767 100644 (file)
@@ -129,11 +129,12 @@ class DatabaseConnect extends AbstractStepAction
             \TYPO3\CMS\Core\Core\Bootstrap::getInstance()
                 ->populateLocalConfiguration()
                 ->disableCoreCache();
-            if (!$this->isConnectSuccessful()) {
+            $exceptionMessage = $this->isConnectSuccessfulWithExceptionMessage();
+            if (!empty($exceptionMessage)) {
                 /** @var $errorStatus \TYPO3\CMS\Install\Status\ErrorStatus */
                 $errorStatus = GeneralUtility::makeInstance(\TYPO3\CMS\Install\Status\ErrorStatus::class);
                 $errorStatus->setTitle('Database connect not successful');
-                $errorStatus->setMessage('Connecting to the database with given settings failed. Please check.');
+                $errorStatus->setMessage('Connecting to the database with given settings failed: ' . $exceptionMessage);
                 $result[] = $errorStatus;
             }
         }
@@ -206,16 +207,26 @@ class DatabaseConnect extends AbstractStepAction
     /**
      * Test connection with given credentials
      *
-     * @return bool TRUE if connect was successful
+     * @return bool true if connect was successful
      */
     protected function isConnectSuccessful()
     {
+        return empty($this->isConnectSuccessfulWithExceptionMessage());
+    }
+
+    /**
+     * Test connection with given credentials and return exception message if exception trown
+     *
+     * @return string
+     */
+    protected function isConnectSuccessfulWithExceptionMessage(): string
+    {
         try {
             GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionByName('Default')->ping();
         } catch (DBALException $e) {
-            return false;
+            return $e->getMessage();
         }
-        return true;
+        return '';
     }
 
     /**