* Create a new view with table style
* Add an exposed filter that exposes a select list
* Add a click sortable column
* Render the page
* Examine the click sortable URL: its query part is corrupt, containing a keyless value, e.g. http://.../tablesort?order=nid&sort=ascAll

This is due to the $view->raw_exposed_input being wrongly processed to create the URL query.

Example view attached. Patch to follow.

CommentFileSizeAuthor
#1 1188828-tablesort.patch720 bytesinfojunkie
tablesort.txt4.09 KBinfojunkie

Comments

infojunkie’s picture

Status: Active » Needs review
StatusFileSize
new720 bytes

This patch fixes the problem for both 6.x-3.x and 6.x-2.x (with offset).

It uses parse_str to manipulate $query as an array, which is easier to handle than a string, then http_build_query to convert the result back to a string when it's done.

dww’s picture

Status: Needs review » Reviewed & tested by the community

Yes, good catch. I just ran into the same problem myself.

Also, the same patch fixes a related bug, which is that if you have an exposed filter with an exposed operation, that element of $view->exposed_raw_input will be a nested array, not just a string, so you end up with the following:

notice: Array to string conversion in /.../sites/all/modules/views/theme/theme.inc on line 415.

Using parse_str for this seems like a really simple, elegant solution (make PHP do the heavy lifting) and it mostly works nicely in my testing (V3 -- I haven't tested V2 yet).

One related thing that appears to be broken is the following sequence:

- load the raw table view
- click on a different column to sort than the default sort
- select a value for an exposed filter and submit

At this point, the filter is applied, but the clicked sort order is lost. However, the same is true before the patch, so it's definitely not making this worse. Not sure if there's already an issue open about that (probably there is).

However, I don't want to commit and push this without dereine or merlin's approval, since this would be the first time views uses parse_str() and Earl might hate this for some reason. ;) But, it's RTBC to my eyes, and hopefully I can get Earl's sign-off ASAP so we can fix this up soon.

Thanks!
-Derek

p.s. You should have searched first since you would have hopefully found #1141392: exposed filters and table sort not getting along which I believe is the same bug. However, since this issue is more clear about the problems and already has a working patch, I'm going to mark that one as duplicate.

dawehner’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Reviewed & tested by the community » Active

Commited to both 6.x branches and wondering whether the bug still exist on 7.x-3.x

jvdurme’s picture

Thanks for this fix!

dawehner’s picture

Status: Active » Fixed

This seems to be fixed in 7.x-3.x already.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.