Commit a52f0b41 authored by gerv%gerv.net's avatar gerv%gerv.net

Bug 155584 - Opening duplicates.cgi with no frequent bugs causes SQL syntax…

Bug 155584 - Opening duplicates.cgi with no frequent bugs causes SQL syntax error. Patch by gerv; r=bbaetz.
parent df194854
...@@ -135,10 +135,14 @@ if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever", ...@@ -135,10 +135,14 @@ if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever",
$dobefore = 1; $dobefore = 1;
} }
# Don't add CLOSED, and don't add VERIFIED unless they are INVALID or my @bugs;
# WONTFIX. We want to see VERIFIED INVALID and WONTFIX because common my @bug_ids;
# "bugs" which aren't bugs end up in this state.
my $query = " if (scalar(%count)) {
# Don't add CLOSED, and don't add VERIFIED unless they are INVALID or
# WONTFIX. We want to see VERIFIED INVALID and WONTFIX because common
# "bugs" which aren't bugs end up in this state.
my $query = "
SELECT bugs.bug_id, component, bug_severity, op_sys, target_milestone, SELECT bugs.bug_id, component, bug_severity, op_sys, target_milestone,
short_desc, bug_status, resolution short_desc, bug_status, resolution
FROM bugs FROM bugs
...@@ -147,17 +151,14 @@ my $query = " ...@@ -147,17 +151,14 @@ my $query = "
OR (bug_status != 'VERIFIED')) OR (bug_status != 'VERIFIED'))
AND bugs.bug_id IN (" . join(", ", keys %count) . ")"; AND bugs.bug_id IN (" . join(", ", keys %count) . ")";
# Limit to a single product if requested # Limit to a single product if requested
$query .= (" AND product = " . SqlQuote($product)) if $product; $query .= (" AND product = " . SqlQuote($product)) if $product;
SendSQL(SelectVisible($query, SendSQL(SelectVisible($query,
$userid, $userid,
$usergroupset)); $usergroupset));
my @bugs; while (MoreSQLData()) {
my @bug_ids;
while (MoreSQLData()) {
# Note: maximum row count is dealt with in the template. # Note: maximum row count is dealt with in the template.
my ($id, $component, $bug_severity, $op_sys, $target_milestone, my ($id, $component, $bug_severity, $op_sys, $target_milestone,
...@@ -177,6 +178,7 @@ while (MoreSQLData()) { ...@@ -177,6 +178,7 @@ while (MoreSQLData()) {
bug_status => $bug_status, bug_status => $bug_status,
resolution => $resolution }); resolution => $resolution });
push (@bug_ids, $id); push (@bug_ids, $id);
}
} }
$vars->{'bugs'} = \@bugs; $vars->{'bugs'} = \@bugs;
......
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
[%# *** Column Headers *** %] [%# *** Column Headers *** %]
<table border> [% IF bug_ids.size > 0 %]
<table border>
<tr bgcolor="#CCCCCC"> <tr bgcolor="#CCCCCC">
[% FOREACH column = [ { name => "id", description => "Bug #" }, [% FOREACH column = [ { name => "id", description => "Bug #" },
{ name => "count", description => "Dupe<br>Count" }, { name => "count", description => "Dupe<br>Count" },
...@@ -85,31 +86,31 @@ ...@@ -85,31 +86,31 @@
[% END %] [% END %]
</tr> </tr>
[% IF NOT sortby %] [% IF NOT sortby %]
[% sortby = "count"; reverse = "1" %] [% sortby = "count"; reverse = "1" %]
[% END %] [% END %]
[% IF sortby == "id" OR sortby == "count" OR sortby == "delta" %] [% IF sortby == "id" OR sortby == "count" OR sortby == "delta" %]
[%# Numeric sort %] [%# Numeric sort %]
[% sortedbugs = bugs.nsort(sortby) %] [% sortedbugs = bugs.nsort(sortby) %]
[% ELSE %] [% ELSE %]
[% sortedbugs = bugs.sort(sortby) %] [% sortedbugs = bugs.sort(sortby) %]
[% END %] [% END %]
[% IF reverse %] [% IF reverse %]
[% bugs = sortedbugs.reverse %] [% bugs = sortedbugs.reverse %]
[% ELSE %] [% ELSE %]
[% bugs = sortedbugs %] [% bugs = sortedbugs %]
[% END %] [% END %]
[%# *** Buglist *** %] [%# *** Buglist *** %]
[%# We need to keep track of the bug IDs we are actually displaying, because [%# We need to keep track of the bug IDs we are actually displaying, because
# if the user decides to sort the visible list, we need to know what that # if the user decides to sort the visible list, we need to know what that
# list actually is. %] # list actually is. %]
[% vis_bug_ids = [] %] [% vis_bug_ids = [] %]
[% FOREACH bug = bugs %] [% FOREACH bug = bugs %]
[% LAST IF loop.index() >= maxrows %] [% LAST IF loop.index() >= maxrows %]
[% vis_bug_ids.push(bug.id) %] [% vis_bug_ids.push(bug.id) %]
...@@ -138,6 +139,9 @@ ...@@ -138,6 +139,9 @@
<td><center>[% bug.target_milestone %]</center></td> <td><center>[% bug.target_milestone %]</center></td>
<td>[% bug.short_desc FILTER html %]</td> <td>[% bug.short_desc FILTER html %]</td>
</tr> </tr>
[% END %] [% END %]
</table> </table>
[% ELSE %]
<h3>No duplicate bugs found.</h3>
[% END %]
...@@ -49,9 +49,6 @@ ...@@ -49,9 +49,6 @@
[% PROCESS "reports/duplicates-table.html.tmpl" %] [% PROCESS "reports/duplicates-table.html.tmpl" %]
<br>
<br>
[%# *** Parameters *** %] [%# *** Parameters *** %]
[% bug_ids_string = vis_bug_ids.join(',') %] [% bug_ids_string = vis_bug_ids.join(',') %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment