Tip Details Add a Related Tip

Rate as: Positive Negative

Reverse sort order in Bugzilla

If you are a user of Bugzilla, you've probably run into the fact that Bugzilla does not allow you to sort in reverse order. When it's showing bugs, you can click on a column header to sort by that column. But the sort is always ascending (smallest result first, largest last) and clicking the same column again does not reverse the order of sort (as it does in many programs). This has frustrated me for a long time, but I've finally found a way around this problem in Bugzilla.

It turns out that when you click on a column to sort by it, Bugzilla stores the actual SQL for the sort in the URL (I won't even go into the security ramifications of something like this, but I suspect/hope they are doing something to mitigate them). For example, If you sort on the "ID" column in Bugzilla and you then look at the URL you'll see a parameter in the URL called "order", this is usually near the end of the URL. Here's an example snippet from the URL:

...&order=bugs.bug_id&...

The thing to note here is that the value of "order" is "bugs.bug_id", which happens to be the table name/column (in the database) on which the sort is occurring. So far as I can tell, Bugzilla takes the value of the "order" parameter and injects it directly into the "order by" statement of the query used to create the results (hopefully with filtering). So, to reverse the sort order in this case, all you need to do is update the "order" parameter to include additional information to indicate a sort direction. In the case of SQL, this is done by adding " desc" to the sort criteria. By changing the above sort criteria to this:

...&order=bugs.bug_id&20desc&...

Bugzilla will return the results sorted in the reverse order, which is descending. Note that the "%20" is just how you represent a space character in a URL.

With this knowledge, you can actually get Bugzilla to perform any type of sort that you'd like. First, in Bugzilla sort by the column(s) you want to include in your sort and look at the resulting URL to get the table and column name used (the format is table_name.column_name). You can then string together multiple sort criteria by using commas to separate them. For example, this URL snippet:

...&order=bugs.bug_status,bugs.bug_id%20desc&...

Would cause Bugzilla to sort first by ascending bug status, and then it would use the bug_id desc (which puts newer bugs near the top) for results that have the same status.

Once you get the feel for this, you can get Bugzilla to perform any type of sort that you'd like. But one thing you don't want to have to do is to hack the URL in Bugzilla every time you want to sort. To save yourself typing, you can save your search once you get the sort order correct and the sort order will be part of the saved search.
Rating: 100% positive, 6 total Votes
Categories: Bugzilla hack programming debugging
Added: on Sep 10, 2007 at 4:26 pm
Added By: rlansky

Comments on this Tip

Add a Comment
the second example, isnt correct... there must be a % instead of &.
takes a while to recognise this... ;)
– Added by an anonymous user on Jun 13, 2008 at 8:43 am
Your Comment:
(how to format)
Rate This Tip:

Verify Humanity:
Sorry, we know it's annoying, but please enter the characters shown in the image to the left so that we know you're an actual person and not an evil spammer. Thanks.
       

Related Tips

Service menu codes for all sorts of TVs

100% positive, 0 comments
– Tip added by an anonymous user on Jan 04, 2008 at 3:51 pm

debugging pages for the iPhone

100% positive, 1 comment - last added on May 11, 2008 at 8:31 pm
– Tip added by an anonymous user on Jul 09, 2007 at 8:24 am

Is your unit test really a unit test

no ratings, 0 comments
– Tip added by hindy on Feb 29, 2008 at 11:06 am

Adding searches to the Finder sidebar

100% positive, 0 comments
– Tip added by an anonymous user on Jun 27, 2008 at 9:07 am

Javascript Error: unterminated regular expression literal

100% positive, 0 comments
– Tip added by marty on Jun 26, 2008 at 1:20 pm

Change the carrier name on your iPhone

50% positive, 0 comments
– Tip added by an anonymous user on Jun 25, 2008 at 1:34 pm

removing private data from an iPhone

Categories: iPhone security hack
100% positive, 0 comments
– Tip added by an anonymous user on Jun 23, 2008 at 12:45 pm

Speed up the Zune software

Categories: Zune speed hack
50% positive, 1 comment - last added 4 days, 8 hours ago
– Tip added by an anonymous user on Jun 23, 2008 at 10:02 am

Minimize round trips to the server for best performance

100% positive, 0 comments
– Tip added by an anonymous user on Jun 18, 2008 at 4:07 pm

Showing all hidden files in Vista

Categories: windows Vista regedit hack
100% positive, 0 comments
– Tip added by an anonymous user on Jun 18, 2008 at 7:44 am

Read magazines on-line for free

100% positive, 0 comments
– Tip added by lemeur on Jun 16, 2008 at 3:04 pm

compressing javascript

100% positive, 0 comments
– Tip added by an anonymous user on Jun 12, 2008 at 3:02 pm

Put custom text on the windows taskbar

100% positive, 0 comments
– Tip added by an anonymous user on Jun 09, 2008 at 2:34 pm

Accessing your Mac drives from Parallels

Categories: Mac parallels hack
100% positive, 0 comments
– Tip added by an anonymous user on May 12, 2008 at 3:56 pm

Hack your Canon digital camera

100% positive, 0 comments
– Tip added by shutterbug on May 08, 2008 at 11:45 am

Unlocking a blackberry

no ratings, 0 comments
– Tip added by an anonymous user on Jun 25, 2008 at 11:03 am

1067 errors in Actionscript

no ratings, 0 comments
– Tip added by an anonymous user on Jun 17, 2008 at 9:28 pm

Referencing methods in PHP usort

Categories: php coding programming
no ratings, 0 comments
– Tip added by an anonymous user on Jun 13, 2008 at 11:18 am

How to convert M4P to MP3

no ratings, 0 comments
– Tip added by an anonymous user on May 16, 2008 at 10:19 am

Cool your XBox 360

Categories: XBox hack
no ratings, 0 comments
– Tip added by an anonymous user on May 09, 2008 at 6:32 am