[BUGFIX] Replace SHOW DATABASE by query to schema
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Database / DatabaseConnection.php
index 5ee7fb9..0234a28 100644 (file)
@@ -1289,17 +1289,24 @@ class DatabaseConnection {
                        $this->connectDB();
                }
                $dbArr = array();
-               $db_list = $this->link->query("SHOW DATABASES");
-               while ($row = $db_list->fetch_object()) {
-                       try {
-                               $this->setDatabaseName($row->Database);
-                               if ($this->sql_select_db()) {
-                                       $dbArr[] = $row->Database;
+               $db_list = $this->link->query("SELECT SCHEMA_NAME FROM information_schema.SCHEMATA");
+               if ($db_list === FALSE) {
+                       throw new \RuntimeException(
+                               'MySQL Error: Cannot get tablenames: "' . $this->sql_error() . '"!',
+                               1378457171
+                       );
+               } else {
+                       while ($row = $db_list->fetch_object()) {
+                               try {
+                                       $this->setDatabaseName($row->SCHEMA_NAME);
+                                       if ($this->sql_select_db()) {
+                                               $dbArr[] = $row->SCHEMA_NAME;
+                                       }
+                               } 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.
                                }
-                       } 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;