diff --git a/ChangeLog b/ChangeLog index 0891dd16c..678179331 100644 --- a/ChangeLog +++ b/ChangeLog @@ -82,6 +82,8 @@ danbarry thanks to Charles Suh - cws125 - bug #2080963 [charset] Clarify doc and improved code, thanks to Victor Volkov - hanut +- bug [charset] Cannot sort twice on a column when the table name + contains accents 2.11.9.0 (2008-08-28) - bug #2031221 [auth] Links to version number on login screen diff --git a/libraries/display_tbl.lib.php b/libraries/display_tbl.lib.php index 6032462bc..f05c01912 100644 --- a/libraries/display_tbl.lib.php +++ b/libraries/display_tbl.lib.php @@ -765,9 +765,9 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $ // If it contains one, it's probably a function column // like 'COUNT(`field`)' if (strpos($name_to_use_in_sort, '(') !== false) { - $sort_order = ' ORDER BY ' . $name_to_use_in_sort . ' '; + $sort_order = 'ORDER BY ' . $name_to_use_in_sort . ' '; } else { - $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($name_to_use_in_sort) . ' '; + $sort_order = 'ORDER BY ' . $sort_tbl . PMA_backquote($name_to_use_in_sort) . ' '; } unset($name_to_use_in_sort); diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php index 490b94b9d..ee3d6dac7 100644 --- a/libraries/sqlparser.lib.php +++ b/libraries/sqlparser.lib.php @@ -1589,9 +1589,12 @@ if (! defined('PMA_MINIMUM_COMMON')) { } if ($seen_order) { $seen_order_by = TRUE; - // here we assume that the ORDER BY keywords took - // exactly 8 characters - $unsorted_query = substr($arr['raw'], 0, $arr[$i]['pos'] - 8); + // Here we assume that the ORDER BY keywords took + // exactly 8 characters. + // We use PMA_substr() to be charset-safe; otherwise + // if the table name contains accents, the unsorted + // query would be missing some characters. + $unsorted_query = PMA_substr($arr['raw'], 0, $arr[$i]['pos'] - 8); $in_order_by = TRUE; $order_by_clause = ''; }