From a52f0b4135b629b9651145ad51bc2791b7feaeac Mon Sep 17 00:00:00 2001 From: "gerv%gerv.net" <> Date: Sat, 10 Aug 2002 16:53:29 +0000 Subject: Bug 155584 - Opening duplicates.cgi with no frequent bugs causes SQL syntax error. Patch by gerv; r=bbaetz. --- duplicates.cgi | 80 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 39 deletions(-) (limited to 'duplicates.cgi') diff --git a/duplicates.cgi b/duplicates.cgi index 52e611cbf..3d0875313 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; -- cgit v1.2.3-24-g4f1b