From: gerv%gerv.net <> Date: Sat, 10 Aug 2002 16:53:29 +0000 (+0000) Subject: Bug 155584 - Opening duplicates.cgi with no frequent bugs causes SQL syntax error... X-Git-Tag: bugzilla-2.17.1~209 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a52f0b4135b629b9651145ad51bc2791b7feaeac;p=thirdparty%2Fbugzilla.git Bug 155584 - Opening duplicates.cgi with no frequent bugs causes SQL syntax error. Patch by gerv; r=bbaetz. --- diff --git a/duplicates.cgi b/duplicates.cgi index 52e611cbf5..3d08753130 100755 --- a/duplicates.cgi +++ b/duplicates.cgi @@ -135,48 +135,50 @@ if (!tie(%before, 'AnyDBM_File', "data/duplicates/dupes$whenever", $dobefore = 1; } -# 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, - short_desc, bug_status, resolution - FROM bugs - WHERE (bug_status != 'CLOSED') - AND ((bug_status = 'VERIFIED' AND resolution IN ('INVALID', 'WONTFIX')) - OR (bug_status != 'VERIFIED')) - AND bugs.bug_id IN (" . join(", ", keys %count) . ")"; - -# Limit to a single product if requested -$query .= (" AND product = " . SqlQuote($product)) if $product; - -SendSQL(SelectVisible($query, - $userid, - $usergroupset)); - my @bugs; my @bug_ids; -while (MoreSQLData()) { - # Note: maximum row count is dealt with in the template. - - my ($id, $component, $bug_severity, $op_sys, $target_milestone, - $short_desc, $bug_status, $resolution) = FetchSQLData(); - - # Limit to open bugs only if requested - next if $openonly && ($resolution ne ""); - - push (@bugs, { id => $id, - count => $count{$id}, - delta => $delta{$id}, - component => $component, - bug_severity => $bug_severity, - op_sys => $op_sys, - target_milestone => $target_milestone, - short_desc => $short_desc, - bug_status => $bug_status, - resolution => $resolution }); - push (@bug_ids, $id); +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, + short_desc, bug_status, resolution + FROM bugs + WHERE (bug_status != 'CLOSED') + AND ((bug_status = 'VERIFIED' AND resolution IN ('INVALID', 'WONTFIX')) + OR (bug_status != 'VERIFIED')) + AND bugs.bug_id IN (" . join(", ", keys %count) . ")"; + + # Limit to a single product if requested + $query .= (" AND product = " . SqlQuote($product)) if $product; + + SendSQL(SelectVisible($query, + $userid, + $usergroupset)); + + while (MoreSQLData()) { + # Note: maximum row count is dealt with in the template. + + my ($id, $component, $bug_severity, $op_sys, $target_milestone, + $short_desc, $bug_status, $resolution) = FetchSQLData(); + + # Limit to open bugs only if requested + next if $openonly && ($resolution ne ""); + + push (@bugs, { id => $id, + count => $count{$id}, + delta => $delta{$id}, + component => $component, + bug_severity => $bug_severity, + op_sys => $op_sys, + target_milestone => $target_milestone, + short_desc => $short_desc, + bug_status => $bug_status, + resolution => $resolution }); + push (@bug_ids, $id); + } } $vars->{'bugs'} = \@bugs; diff --git a/template/en/default/reports/duplicates-table.html.tmpl b/template/en/default/reports/duplicates-table.html.tmpl index 83499b377d..ae9f074a9b 100644 --- a/template/en/default/reports/duplicates-table.html.tmpl +++ b/template/en/default/reports/duplicates-table.html.tmpl @@ -44,100 +44,104 @@ [%# *** Column Headers *** %] - - - [% FOREACH column = [ { name => "id", description => "Bug #" }, - { name => "count", description => "Dupe
Count" }, - { name => "delta", - description => "Change in last
$changedsince day(s)" }, - { name => "component", description => "Component" }, - { name => "bug_severity", description => "Severity" }, - { name => "op_sys", description => "Op Sys" }, - { name => "target_milestone", - description => "Target
Milestone" }, - { name => "short_desc", description => "Summary" } ] - %] - - [%# Small hack to keep delta column out if we don't need it %] - [% NEXT IF column.name == "delta" AND NOT dobefore %] +[% IF bug_ids.size > 0 %] +
+ + [% FOREACH column = [ { name => "id", description => "Bug #" }, + { name => "count", description => "Dupe
Count" }, + { name => "delta", + description => "Change in last
$changedsince day(s)" }, + { name => "component", description => "Component" }, + { name => "bug_severity", description => "Severity" }, + { name => "op_sys", description => "Op Sys" }, + { name => "target_milestone", + description => "Target
Milestone" }, + { name => "short_desc", description => "Summary" } ] + %] - - [% END %] - - -[% IF NOT sortby %] - [% sortby = "count"; reverse = "1" %] -[% END %] + [%# Small hack to keep delta column out if we don't need it %] + [% NEXT IF column.name == "delta" AND NOT dobefore %] -[% IF sortby == "id" OR sortby == "count" OR sortby == "delta" %] - [%# Numeric sort %] - [% sortedbugs = bugs.nsort(sortby) %] -[% ELSE %] - [% sortedbugs = bugs.sort(sortby) %] -[% END %] + + [% END %] + -[% IF reverse %] - [% bugs = sortedbugs.reverse %] -[% ELSE %] - [% bugs = sortedbugs %] -[% END %] + [% IF NOT sortby %] + [% sortby = "count"; reverse = "1" %] + [% END %] -[%# *** Buglist *** %] + [% IF sortby == "id" OR sortby == "count" OR sortby == "delta" %] + [%# Numeric sort %] + [% sortedbugs = bugs.nsort(sortby) %] + [% ELSE %] + [% sortedbugs = bugs.sort(sortby) %] + [% END %] -[%# 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 - # list actually is. %] -[% vis_bug_ids = [] %] + [% IF reverse %] + [% bugs = sortedbugs.reverse %] + [% ELSE %] + [% bugs = sortedbugs %] + [% END %] -[% FOREACH bug = bugs %] - [% LAST IF loop.index() >= maxrows %] - [% vis_bug_ids.push(bug.id) %] + [%# *** Buglist *** %] - - + [%# 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 + # list actually is. %] + [% vis_bug_ids = [] %] - + [% FOREACH bug = bugs %] + [% LAST IF loop.index() >= maxrows %] + [% vis_bug_ids.push(bug.id) %] - [% IF dobefore %] - - [% END %] + + - - - - - - -[% END %] + + + [% IF dobefore %] + + [% END %] + + + + + + + + [% END %] -
-
- - [% bug_ids_string = bug_ids.join(',') %] - - [% column.description %] - -
-
+
+ + [% bug_ids_string = bug_ids.join(',') %] + + [% column.description %] + +
+
-
- [% "" IF bug.resolution != "" %] - [% bug.id %] - [% "" IF bug.resolution != "" %] -
-
-
- [% bug.count %] -
-
[% bug.delta %]
+
+ [% "" IF bug.resolution != "" %] + [% bug.id %] + [% "" IF bug.resolution != "" %] +
+
[% bug.component %]
[% bug.bug_severity %]
[% bug.op_sys %]
[% bug.target_milestone %]
[% bug.short_desc FILTER html %]
+
+ [% bug.count %] +
+
[% bug.delta %]
[% bug.component %]
[% bug.bug_severity %]
[% bug.op_sys %]
[% bug.target_milestone %]
[% bug.short_desc FILTER html %]
+ +[% ELSE %] +

No duplicate bugs found.

+[% END %] diff --git a/template/en/default/reports/duplicates.html.tmpl b/template/en/default/reports/duplicates.html.tmpl index 64ba5e120d..531196eb82 100644 --- a/template/en/default/reports/duplicates.html.tmpl +++ b/template/en/default/reports/duplicates.html.tmpl @@ -49,9 +49,6 @@ [% PROCESS "reports/duplicates-table.html.tmpl" %] -
-
- [%# *** Parameters *** %] [% bug_ids_string = vis_bug_ids.join(',') %]