Using any of the _realname columns in Search.pm generates a SQL error

RESOLVED FIXED in Bugzilla 4.2

Status

()

Bugzilla
Reporting/Charting
RESOLVED FIXED
7 years ago
7 years ago

People

(Reporter: Frédéric Buclin, Assigned: Max Kanat-Alexander)

Tracking

({regression})

Bugzilla 4.2
regression
Bug Flags:
approval +

Details

(URL)

Attachments

(2 attachments)

(Reporter)

Description

7 years ago
When using the assignee/reporter/QA contact real names as row/column in tabular reports, the DB crashes with:

On MySQL:

DBD::mysql::db selectall_arrayref failed: Unknown column 'map_assigned_to.realname' in 'field list' [for Statement "SELECT map_assigned_to.realname AS assigned_to_realname, map_reporter.realname AS reporter_realname, -1
  FROM bugs
LEFT JOIN bug_group_map AS security_map ON bugs.bug_id = security_map.bug_id AND NOT ( security_map.group_id IN (1,12,10,11,13,9,4,8,5,6,7,3,2,29,26,28,27,18,14,20,15,16,17) )
LEFT JOIN cc AS security_cc ON bugs.bug_id = security_cc.bug_id AND security_cc.who = 1
 WHERE bugs.creation_ts IS NOT NULL
   AND (security_map.group_id IS NULL OR (bugs.reporter_accessible = 1 AND bugs.reporter = 1)
 OR (bugs.cclist_accessible = 1 AND security_cc.who IS NOT NULL)
 OR bugs.assigned_to = 1
 OR bugs.qa_contact = 1)
GROUP BY bugs.bug_id
"] at /var/www/html/bugzilla/report.cgi line 137
 at /var/www/html/bugzilla/report.cgi line 137


On PostgreSQL:

DBD::Pg::db selectall_arrayref failed: ERROR:  missing FROM-clause entry for table "map_assigned_to"
LINE 1: SELECT map_assigned_to.realname AS assigned_to_realname, map...
               ^ [for Statement "SELECT map_assigned_to.realname AS assigned_to_realname, map_reporter.realname AS reporter_realname, -1
  FROM bugs
LEFT JOIN bug_group_map AS security_map ON bugs.bug_id = security_map.bug_id
 WHERE bugs.creation_ts IS NOT NULL
   AND security_map.group_id IS NULL
GROUP BY bugs.bug_id, map_assigned_to.realname,map_reporter.realname
"] at /var/www/html/bugzilla-pg/report.cgi line 137
 at /var/www/html/bugzilla-pg/report.cgi line 137


This was working fine in Bugzilla 4.0rc1, but fails in 4.1. Bugzilla 3.6 is not affected as these fields are not selectable in the 3.6.x series.
(Assignee)

Comment 1

7 years ago
Okay, this is just a Search.pm regression from the refactoring, I think it will be very simple to fix.
Assignee: charting → mkanat
(Reporter)

Comment 2

7 years ago
Could you fix xt/ tests to include a check for this? :)
(Assignee)

Comment 3

7 years ago
(In reply to comment #2)
> Could you fix xt/ tests to include a check for this? :)

  Ah, I don't think so, not that easily. I'll have to see what the bug is, though.
(Assignee)

Comment 4

7 years ago
Created attachment 516206 [details] [diff] [review]
v1

Okay here's a really simple patch that fixes this. I also got a test for it into xt! :-)
Attachment #516206 - Flags: review+
(Assignee)

Updated

7 years ago
Flags: approval+
(Assignee)

Updated

7 years ago
Summary: Tabular reports involving real names generate a SQL error → Using any of the _realname columns in Search.pm generates a SQL error
(Assignee)

Comment 5

7 years ago
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/                       
modified Bugzilla/Search.pm
modified xt/lib/Bugzilla/Test/Search/FieldTestNormal.pm
Committed revision 7732
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
(Reporter)

Comment 6

7 years ago
This doesn't fix comment 0 at all. Instead of the crash, I now get:

 There is no field named 'reporter_realname'

Same for the assignee and QA contact.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
(Assignee)

Comment 7

7 years ago
Hmm, weird. Well, it works fine in buglist.cgi now. And it did change the error message, at least (although to something that doesn't make sense). I wouldn't block 4.1.1 on not being able to use realname as an axis, but it should still totally be fixed.
(Assignee)

Comment 8

7 years ago
Created attachment 517937 [details] [diff] [review]
Fix report.cgi

Okay, this very simple patch fixes the problem in report.cgi.
Attachment #517937 - Flags: review?(LpSolit)
(Reporter)

Comment 9

7 years ago
Comment on attachment 517937 [details] [diff] [review]
Fix report.cgi

>+    $field = Bugzilla::Field->check($field_name) 
>+            # _realname fields aren't real Bugzilla::Field objects,
>+            # but they are a valid axis.
>+        if ($field_name && $field_name !~ /_realname$/);

Please fix the indentation of the comment. Also, it would make more sense to have the comment above the first line instead of being in the middle of the code (it makes it easy to miss the if() condition). r=LpSolit with these fixes.
Attachment #517937 - Flags: review?(LpSolit) → review+
(Assignee)

Comment 10

7 years ago
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/                       
modified report.cgi
Committed revision 7768.
Status: REOPENED → RESOLVED
Last Resolved: 7 years ago7 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.