[BUGFIX] Cannot connect to the current database 48/20848/2
authorOliver Hader <oliver@typo3.org>
Mon, 13 May 2013 12:49:15 +0000 (14:49 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 16 May 2013 18:52:53 +0000 (20:52 +0200)
DatabaseConnection::admin_get_dbs() iterates over all existing
databases during install process and tries to use each of them.
If that fails, an exception is thrown - which is not caught in
the mentioned method.

Change-Id: I5fdf08b867ead6535ce737fdceb86a977b539462
Fixes: #48138
Releases: 6.0, 6.1, 6.2
Reviewed-on: https://review.typo3.org/20848
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Database/DatabaseConnection.php

index 2287d77..ef8a3c3 100644 (file)
@@ -1287,9 +1287,15 @@ class DatabaseConnection {
                $dbArr = array();
                $db_list = $this->link->query("SHOW DATABASES");
                while ($row = $db_list->fetch_object()) {
-                       $this->setDatabaseName($row->Database);
-                       if ($this->sql_select_db()) {
-                               $dbArr[] = $row->Database;
+                       try {
+                               $this->setDatabaseName($row->Database);
+                               if ($this->sql_select_db()) {
+                                       $dbArr[] = $row->Database;
+                               }
+                       } catch (\RuntimeException $exception) {
+                               // The exception happens if we cannot connect to the database
+                               // (usually due to missing permissions). This is ok here.
+                               // We catch the exception, skip the database and continue.
                        }
                }
                return $dbArr;