can use undefined alias in ORDER BY clause for %old_names fields

RESOLVED FIXED in Bugzilla 4.2



7 years ago
7 years ago


(Reporter: davidt, Assigned: LpSolit)



Bugzilla 4.2
Bug Flags:
approval +
approval4.2 +
blocking4.2.1 +




(1 attachment)



7 years ago
After upgrading from 4.0 to 4.2, some saved queries started causing an Internal Server Error.  After investigation, this appears to be due to the query being sorted by changed date, but not including the changed date in the set of displayed columns.  I'm not sure that's a valid saved query, but I somehow managed to create it in 4.0, and it worked until now - and it shouldn't cause a crash.

I have reproduced the problem on - see the URL.

The problem seems to be due to the %old_names translation in  The code uses the 'changeddate' name in the ORDER BY clause, which is normally fine if the change date is in the displayed fields as delta_ts will have been aliased to changeddate and the ORDER BY will work.  When the field is not displayed, the alias is undefined and the query fails.

Comment 1

7 years ago
OK, now I feel silly - I tried to simplify the test case, but actually it worked correctly.  For some reason the bug only shows up when searching by classification.  The revised test URL shows the problem for both changeddate and opendate.

Comment 2

7 years ago
I can reproduce using your new URL. Thanks for catching that.
Ever confirmed: true
Flags: blocking4.2.1+
Keywords: regression
Target Milestone: --- → Bugzilla 4.2

Comment 3

7 years ago
For the record:

DBD::mysql::st execute failed: Unknown column 'opendate' in 'order clause' [for Statement "SELECT bugs.bug_id AS bug_id, bugs.bug_severity AS bug_severity, bugs.priority AS priority, bugs.bug_status AS bug_status, bugs.resolution AS resolution, AS product
  FROM bugs
LEFT JOIN bug_group_map AS security_map ON bugs.bug_id = security_map.bug_id
INNER JOIN products AS map_product ON bugs.product_id =
 WHERE bugs.creation_ts IS NOT NULL
   AND security_map.group_id IS NULL
   AND map_product.classification_id IN (SELECT FROM classifications WHERE IN ('Test') ) AND bugs.delta_ts >= '2012-01-28 03:29:14' AND bugs.creation_ts >= '2012-01-28 03:29:14'
GROUP BY bugs.bug_id
ORDER BY opendate DESC, changeddate DESC
"] at /var/www/html/bugzilla-4.2-branch/buglist.cgi line 834

Comment 4

7 years ago
Created attachment 602952 [details] [diff] [review]
patch, v1

The reason it fails when the classification column is displayed is because _classification_nonchanged() calls _add_extra_column('product'), and once $self->{extra_columns} is populated, _valid_order_columns() is ignored, which is incorrect.
Assignee: query-and-buglist → LpSolit
Attachment #602952 - Flags: review?(dkl)
Comment on attachment 602952 [details] [diff] [review]
patch, v1

Review of attachment 602952 [details] [diff] [review]:

Looks good and fixes the issue reported in my testing. r=dkl
Attachment #602952 - Flags: review?(dkl) → review+


7 years ago
Flags: approval4.2+
Flags: approval+

Comment 6

7 years ago
Committing to: bzr+ssh://
modified Bugzilla/
Committed revision 8152.

Committing to: bzr+ssh://
modified Bugzilla/
Committed revision 8050.
Last Resolved: 7 years ago
Resolution: --- → FIXED


7 years ago
Duplicate of this bug: 734844
You need to log in before you can comment on or make changes to this bug.