Closed (won't fix)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 May 2006 at 23:26 UTC
Updated:
20 Apr 2010 at 19:10 UTC
I noticed this last week in 4.6.x and it's still here in 4.7.0.
When building a sortable table/pager with theme_pager, the array elements 'data' and 'field' are getting mismatched.
It seems the tablesort wants to sort the table using the data field as well as using this for display (the 'field' element doesn't appear to get referenced?!).
Anyhow, here's my fix (sorry it's not a patch):
file: tablesort.inc
line: 77
orig. code:
$cell['data'] = l($cell['data'] . $image, $_GET['q'], array('title' => $title), 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']) .'&'. $ts['query_string'], NULL, FALSE, TRUE);
changed code:
$cell['data'] = l($cell['data'] . $image, $_GET['q'], array('title' => $title), 'sort='. $ts['sort'] .'&order='. urlencode($cell['field']) .'&'. $ts['query_string'], NULL, FALSE, TRUE);
Comments
Comment #1
fronbow commentedAfter further inspection, the above is wrong.
the line should be changed to
$cell['data'] = l($cell['field'] . $image, $_GET['q'], array('title' => $title), 'sort='. $ts['sort'] .'&order='. urlencode($cell['data']). $ts['query_string'], NULL, FALSE, TRUE);?>
It's the initial cell that's wrong (1st one inside the link).
Comment #2
magico commentedComment #3
(not verified) commentedComment #4
mandclu commentedI'm seing this same behaviour in 5.1. Was this actually fixed in the core code?
Comment #5
danielnolde commentedI just run accross the same bug, according to Drupal API Docs this still is buggy and NOT fixed for D5, D6 *and* D7. This is really a bug and *not* in line with the specification of table header parameter usage, see
http://api.drupal.org/api/function/theme_table
The plain trivial proposed here is correct, applied in seconds and works for for all versions.
Please commit/include.
Comment #6
bradweikel commentedDon't know anything about this issue, but it looks like it needs to be checked in D7 first and then backported if it gets fixed.
Comment #7
aspilicious commentedIn drupal 7 I can't find that specific line anymore, so I don't think this is a drupal 7 problem
Comment #8
berdirThis is not a bug.
data is used to not expose the internal field name. Internally, field is then used to do the actual query.
The code in D7 looks like this:
As you can see, it compares the data value but then uses field for the 'sql' key, which is then used in the ORDER BY. Also, this code hasn't changed since 4.6 except for being E_NOTICE free: http://api.drupal.org/api/function/tablesort_get_order/4.6
Setting to won't fix.