From 0ae77814a7b1f2f9fa08aac741b0157fe6393a1d Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Wed, 1 Jan 2014 18:41:09 +0530 Subject: [PATCH] bug #4208 Can't browse tables after sorting on columns with fieldnames that have a '-' Signed-off-by: Madhura Jayaratne --- ChangeLog | 1 + libraries/sql.lib.php | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f32c68caac..10b81f81b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ phpMyAdmin - ChangeLog 4.1.4.0 (not yet released) - bug #3840 (additional fix) When exporting to gzip format, the data is compressed 2 times +- bug #4208 Can't browse tables after sorting on columns with fieldnames that have a '-' 4.1.3.0 (2013-12-31) - bug #3938 PDFDefaultPageSize doc and easy configurability diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 788a9d9bca..35ebf2d94e 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -230,10 +230,11 @@ function PMA_handleSortOrder($db, $table, &$analyzed_sql_results, &$full_sql_que if (empty($analyzed_sql_results['analyzed_sql'][0]['order_by_clause'])) { $sorted_col = $pmatable->getUiProp(PMA_Table::PROP_SORTED_COLUMN); if ($sorted_col) { - //remove the backquoting and tablename from retrieved preference - //to get just column name - $sorted_col = str_replace('`', '', $sorted_col); - $sorted_col = str_replace($table . '.', '', $sorted_col); + //remove the tablename from retrieved preference + //to get just the column name and the sort order + $sorted_col = str_replace( + PMA_Util::backquote($table) . '.', '', $sorted_col + ); // retrieve the remembered sorting order for current table $sql_order_to_append = ' ORDER BY ' . $sorted_col . ' '; $full_sql_query @@ -2278,7 +2279,7 @@ function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, // Handle remembered sorting order, only for single table query // Handling is not required when it's a union query // (the parser never sets the 'union' key to 0) - if (PMA_isRememberSortingOrder($analyzed_sql_results) + if (PMA_isRememberSortingOrder($analyzed_sql_results) && ! isset($analyzed_sql_results['analyzed_sql'][0]['queryflags']['union']) ) { PMA_handleSortOrder($db, $table, $analyzed_sql_results, $full_sql_query);