From 1086b2a6eeb8b14dea12f24b90d2b4aab4f65bb8 Mon Sep 17 00:00:00 2001 From: Petr Duda Date: Sun, 13 Sep 2020 19:13:29 +0200 Subject: [PATCH] Fix #12961 Indexes shown at both tbl_structure and tbl_relation Signed-off-by: Petr Duda --- .../Controllers/Table/RelationController.php | 4 - templates/table/relation/common_form.twig | 105 ------------------ .../Table/RelationControllerTest.php | 19 ---- .../Table/StructureControllerTest.php | 20 ++++ 4 files changed, 20 insertions(+), 128 deletions(-) diff --git a/libraries/classes/Controllers/Table/RelationController.php b/libraries/classes/Controllers/Table/RelationController.php index 45ca719265..2977241c50 100644 --- a/libraries/classes/Controllers/Table/RelationController.php +++ b/libraries/classes/Controllers/Table/RelationController.php @@ -172,7 +172,6 @@ final class RelationController extends AbstractController // common form $engine = $this->dbi->getTable($this->db, $this->table)->getStorageEngine(); - $foreignKeySupported = Util::isForeignKeySupported($storageEngine); $this->render('table/relation/common_form', [ 'is_foreign_key_supported' => Util::isForeignKeySupported($engine), 'db' => $this->db, @@ -191,9 +190,6 @@ final class RelationController extends AbstractController 'databases' => $GLOBALS['dblist']->databases, 'dbi' => $this->dbi, 'default_sliders_state' => $GLOBALS['cfg']['InitialSlidersState'], - 'foreignKeySupported' => $foreignKeySupported, - 'indexes' => $foreignKeySupported ? Index::getFromTable($this->table, $this->db) : null, - 'indexes_duplicates' => $foreignKeySupported ? Index::findDuplicates($this->table, $this->db) : null, 'route' => $route, ]); } diff --git a/templates/table/relation/common_form.twig b/templates/table/relation/common_form.twig index accd923ec3..e11e0c958c 100644 --- a/templates/table/relation/common_form.twig +++ b/templates/table/relation/common_form.twig @@ -216,109 +216,4 @@ -{% if foreignKeySupported %} -
-
- - {% trans 'Indexes' %} - {{ show_mysql_docu('optimizing-database-structure') }} - - - {% if indexes is not empty %} - {{ indexes_duplicates|raw }} - -
- - - - - - - - - - - - - - - - - {% for index in indexes %} - - {% set columns_count = index.getColumnCount() %} - - - - - - - - - {% for column in index.getColumns() %} - {% if column.getSeqInIndex() > 1 %} - - {% endif %} - - - - - - {% if column.getSeqInIndex() == 1 %} - - {% endif %} - - {% endfor %} - - {% endfor %} -
{% trans 'Action' %}{% trans 'Keyname' %}{% trans 'Type' %}{% trans 'Unique' %}{% trans 'Packed' %}{% trans 'Column' %}{% trans 'Cardinality' %}{% trans 'Collation' %}{% trans 'Null' %}{% trans 'Comment' %}
{{ index.getName() }}{{ index.getType()|default(index.getChoice()) }}{{ index.isUnique() ? 'Yes'|trans : 'No'|trans }}{{ index.isPacked()|raw }}
- {{ column.getName() }} - {% if column.getSubPart() is not empty %} - ({{ column.getSubPart() }}) - {% endif %} - {{ column.getCardinality() }}{{ column.getCollation() }}{{ column.getNull(true) }}{{ index.getComments() }}
-
- {% else %} -
{{ 'No index defined!'|trans|notice }}
- {% endif %} -
- - -
-{% endif %} - {% endblock %} diff --git a/test/classes/Controllers/Table/RelationControllerTest.php b/test/classes/Controllers/Table/RelationControllerTest.php index ebc20b0d60..98f7db225e 100644 --- a/test/classes/Controllers/Table/RelationControllerTest.php +++ b/test/classes/Controllers/Table/RelationControllerTest.php @@ -60,28 +60,9 @@ class RelationControllerTest extends AbstractTestCase } }; - $indexes = [ - [ - 'Schema' => 'Schema1', - 'Key_name' => 'Key_name1', - 'Column_name' => 'Column_name1', - ], - [ - 'Schema' => 'Schema2', - 'Key_name' => 'Key_name2', - 'Column_name' => 'Column_name2', - ], - [ - 'Schema' => 'Schema3', - 'Key_name' => 'Key_name3', - 'Column_name' => 'Column_name3', - ], - ]; $dbi = $this->getMockBuilder(DatabaseInterface::class) ->disableOriginalConstructor() ->getMock(); - $dbi->expects($this->any())->method('getTableIndexes') - ->will($this->returnValue($indexes)); $GLOBALS['dbi'] = $dbi; diff --git a/test/classes/Controllers/Table/StructureControllerTest.php b/test/classes/Controllers/Table/StructureControllerTest.php index 437a34c3eb..4ae8ff8259 100644 --- a/test/classes/Controllers/Table/StructureControllerTest.php +++ b/test/classes/Controllers/Table/StructureControllerTest.php @@ -51,6 +51,24 @@ class StructureControllerTest extends AbstractTestCase $GLOBALS['cfg']['Server']['user'] = 'pma_user'; $GLOBALS['PMA_PHP_SELF'] = 'index.php'; + $indexes = [ + [ + 'Schema' => 'Schema1', + 'Key_name' => 'Key_name1', + 'Column_name' => 'Column_name1', + ], + [ + 'Schema' => 'Schema2', + 'Key_name' => 'Key_name2', + 'Column_name' => 'Column_name2', + ], + [ + 'Schema' => 'Schema3', + 'Key_name' => 'Key_name3', + 'Column_name' => 'Column_name3', + ], + ]; + $table = $this->getMockBuilder(Table::class) ->disableOriginalConstructor() ->getMock(); @@ -60,6 +78,8 @@ class StructureControllerTest extends AbstractTestCase ->getMock(); $dbi->expects($this->any())->method('getTable') ->will($this->returnValue($table)); + $dbi->expects($this->any())->method('getTableIndexes') + ->will($this->returnValue($indexes)); $GLOBALS['dbi'] = $dbi;