[BUGFIX] dbal: make admin_get_tables() return correct table information 37/39637/4
authorMorton Jonuschat <m.jonuschat@mojocode.de>
Wed, 20 May 2015 19:26:35 +0000 (21:26 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Thu, 9 Jul 2015 18:35:14 +0000 (20:35 +0200)
Return the table information in the documented format (array with
tablenames as key and arrays with status information as value).

Resolves: #67067
Releases: master, 6.2
Change-Id: I7a35c5cfdaa469c407f5c4e4f80b55625034be91
Reviewed-on: http://review.typo3.org/39637
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/dbal/Classes/Database/DatabaseConnection.php
typo3/sysext/dbal/Tests/Unit/Database/DatabaseConnectionOracleTest.php
typo3/sysext/dbal/Tests/Unit/Database/DatabaseConnectionTest.php

index ba6041e..048d5fe 100644 (file)
@@ -2585,7 +2585,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                                                        // Skip tables from the Oracle 10 Recycle Bin
                                                        continue;
                                                }
-                                               $whichTables[$theTable] = $theTable;
+                                               $whichTables[$theTable] = array('Name' => $theTable);
                                        }
                                }
                                break;
@@ -2607,6 +2607,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                        foreach ($whichTables as $tN => $tDefinition) {
                                if (isset($tMap[$tN])) {
                                        $tN = $tMap[$tN];
+                                       $tDefinition = array('Name' => $tN);
                                }
                                $newList[$tN] = $tDefinition;
                        }
@@ -2615,7 +2616,7 @@ class DatabaseConnection extends \TYPO3\CMS\Core\Database\DatabaseConnection {
                // Adding tables configured to reside in other DBMS (handler by other handlers than the default):
                if (is_array($this->table2handlerKeys)) {
                        foreach ($this->table2handlerKeys as $key => $handlerKey) {
-                               $whichTables[$key] = $key;
+                               $whichTables[$key] = array('Name' => $key);
                        }
                }
                return $whichTables;
index 085e894..2d40e0b 100644 (file)
@@ -317,6 +317,20 @@ class DatabaseConnectionOracleTest extends AbstractTestCase {
 
        /**
         * @test
+        * @see https://forge.typo3.org/issues/67067
+        */
+       public function tablesAreUnmappedInAdminGetTables() {
+               $handlerMock = $this->getMock('\ADODB_mock', array('MetaTables'), array(), '', FALSE);
+               $handlerMock->expects($this->any())->method('MetaTables')->will($this->returnValue(array('cf_cache_hash')));
+               $this->subject->handlerInstance['_DEFAULT'] = $handlerMock;
+
+               $actual = $this->subject->admin_get_tables();
+               $expected = array('cachingframework_cache_hash' => array('Name' => 'cachingframework_cache_hash'));
+               $this->assertSame($expected, $actual);
+       }
+
+       /**
+        * @test
         * @see http://forge.typo3.org/issues/17918
         */
        public function fieldWithinSqlFunctionIsRemapped() {
index 0dce402..2afc2f8 100644 (file)
@@ -116,6 +116,21 @@ class DatabaseConnectionTest extends AbstractTestCase {
 
        /**
         * @test
+        * @see https://forge.typo3.org/issues/67067
+        */
+       public function adminGetTablesReturnsArrayWithNameKey() {
+               $handlerMock = $this->getMock('\ADODB_mock', array('MetaTables'), array(), '', FALSE);
+               $handlerMock->expects($this->any())->method('MetaTables')->will($this->returnValue(array('cf_cache_hash')));
+               $this->subject->handlerCfg['_DEFAULT']['type'] = 'adodb';
+               $this->subject->handlerInstance['_DEFAULT'] = $handlerMock;
+
+               $actual = $this->subject->admin_get_tables();
+               $expected = array('cf_cache_hash' => array('Name' => 'cf_cache_hash'));
+               $this->assertSame($expected, $actual);
+       }
+
+       /**
+        * @test
         * @see http://forge.typo3.org/issues/21502
         */
        public function concatCanBeParsedAfterLikeOperator() {