quick fix for issue #3383711

Signed-off-by: Sven Strickroth <email@cs-ware.de>
This commit is contained in:
Sven Strickroth
2011-08-01 16:05:36 +02:00
committed by Madhura Jayaratne
parent e466dec53b
commit 7909da2ea0

View File

@@ -766,8 +766,10 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// the orgname member does not exist for all MySQL versions
// but if found, it's the one on which to sort
$name_to_use_in_sort = $fields_meta[$i]->name;
$is_orgname = false;
if (isset($fields_meta[$i]->orgname) && strlen($fields_meta[$i]->orgname)) {
$name_to_use_in_sort = $fields_meta[$i]->orgname;
$is_orgname = true;
}
// $name_to_use_in_sort might contain a space due to
// formatting of function expressions like "COUNT(name )"
@@ -794,12 +796,14 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// 2.1.3 Check the field name for a bracket.
// If it contains one, it's probably a function column
// like 'COUNT(`field`)'
if (strpos($name_to_use_in_sort, '(') !== false) {
// This check is not sufficient, see bug #3383711, it still might be a column name of a view, check is_orgname
if (strpos($name_to_use_in_sort, '(') !== false && !$is_orgname) {
$sort_order = ' ORDER BY ' . $name_to_use_in_sort . ' ';
} else {
$sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($name_to_use_in_sort) . ' ';
}
unset($name_to_use_in_sort);
unset($is_orgname);
// 2.1.4 Do define the sorting URL
if (! $is_in_sort) {