From 4f151204d28de51f27cd43d8cad525b76c336ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 2 Feb 2017 15:11:22 +0100 Subject: [PATCH 1/2] Fix more tables where table sorting is not honored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #12941 Signed-off-by: Michal Čihař --- libraries/DatabaseInterface.php | 6 +++++- templates/table/relation/foreign_key_row.phtml | 6 +++--- templates/table/relation/internal_relational_row.phtml | 5 ++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libraries/DatabaseInterface.php b/libraries/DatabaseInterface.php index d5445ac6cd..5161b73038 100644 --- a/libraries/DatabaseInterface.php +++ b/libraries/DatabaseInterface.php @@ -319,13 +319,17 @@ class DatabaseInterface */ public function getTables($database, $link = null) { - return $this->fetchResult( + $tables = $this->fetchResult( 'SHOW TABLES FROM ' . Util::backquote($database) . ';', null, 0, $link, self::QUERY_STORE ); + if ($GLOBALS['cfg']['NaturalOrder']) { + uksort($tables, 'strnatcasecmp'); + } + return $tables; } /** diff --git a/templates/table/relation/foreign_key_row.phtml b/templates/table/relation/foreign_key_row.phtml index 210a8af303..274bbc7322 100644 --- a/templates/table/relation/foreign_key_row.phtml +++ b/templates/table/relation/foreign_key_row.phtml @@ -65,9 +65,9 @@ if ($foreign_db) { $tables[] = $row[0]; } } -} -if ($GLOBALS['cfg']['NaturalOrder']) { - uksort($tables, 'strnatcasecmp'); + if ($GLOBALS['cfg']['NaturalOrder']) { + uksort($tables, 'strnatcasecmp'); + } } ?> diff --git a/templates/table/relation/internal_relational_row.phtml b/templates/table/relation/internal_relational_row.phtml index 47bc45f972..2ac12b1695 100644 --- a/templates/table/relation/internal_relational_row.phtml +++ b/templates/table/relation/internal_relational_row.phtml @@ -31,6 +31,9 @@ if ($foreign_db) { while ($row = $GLOBALS['dbi']->fetchRow($tables_rs)) { $tables[] = $row[0]; } + if ($GLOBALS['cfg']['NaturalOrder']) { + uksort($tables, 'strnatcasecmp'); + } } // column dropdown @@ -76,4 +79,4 @@ if ($foreign_db && $foreign_table) { ) ); ?> - \ No newline at end of file + From f67ac81675bacc05fe7d5c071b5573b4462535e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 2 Feb 2017 15:12:20 +0100 Subject: [PATCH 2/2] Use getTables instead of contructing the list again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We do not need any condition here as in native relations. Issue #12941 Signed-off-by: Michal Čihař --- .../table/relation/internal_relational_row.phtml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/templates/table/relation/internal_relational_row.phtml b/templates/table/relation/internal_relational_row.phtml index 2ac12b1695..8d16173a5e 100644 --- a/templates/table/relation/internal_relational_row.phtml +++ b/templates/table/relation/internal_relational_row.phtml @@ -23,17 +23,7 @@ if ($foreign_db) { if (isset($existrel[$myfield])) { $foreign_table = $existrel[$myfield]['foreign_table']; } - $tables_rs = $GLOBALS['dbi']->query( - 'SHOW TABLES FROM ' . PMA\libraries\Util::backquote($foreign_db), - null, - PMA\libraries\DatabaseInterface::QUERY_STORE - ); - while ($row = $GLOBALS['dbi']->fetchRow($tables_rs)) { - $tables[] = $row[0]; - } - if ($GLOBALS['cfg']['NaturalOrder']) { - uksort($tables, 'strnatcasecmp'); - } + $tables = $GLOBALS['dbi']->getTables(); } // column dropdown