[BUGFIX] DBAL: Ensure correct mysqli resource for admin_get_tables query 06/52106/2
authorNicole Cordes <typo3@cordes.co>
Mon, 20 Mar 2017 18:01:34 +0000 (19:01 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 11 May 2017 15:24:50 +0000 (17:24 +0200)
The admin_get_tables method tries to fetch all available database tables
from the default connection. But using the native mode, the query is
executed with the $this->lastHandlerKey link which might not be the
default connection. This patch ensures the correct mysqli resource is
used to resolve the database queries.

Resolves: #80358
Releases: 7.6
Change-Id: I3b8224e5377aad64e556052bbea37dae39ca1bb7
Reviewed-on: https://review.typo3.org/52106
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Reviewed-by: Elmar Hinz <t3elmar@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php

index b225d98..ed7180e 100644 (file)
@@ -2737,6 +2737,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection
     {
         $whichTables = [];
         // Getting real list of tables:
+        $this->lastHandlerKey = '_DEFAULT';
         switch ($this->handlerCfg['_DEFAULT']['type']) {
             case 'native':
                 $tables_result = $this->query('SHOW TABLE STATUS FROM `' . TYPO3_db . '`');
@@ -2744,8 +2745,8 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection
                     while ($theTable = $this->sql_fetch_assoc($tables_result)) {
                         $whichTables[$theTable['Name']] = $theTable;
                     }
+                    $tables_result->free();
                 }
-                $tables_result->free();
                 break;
             case 'adodb':
                 // check needed for install tool - otherwise it will just die because the call to