summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjocuri%softhome.net <>2004-12-11 09:05:41 +0100
committerjocuri%softhome.net <>2004-12-11 09:05:41 +0100
commitdf48c469975515876988677ed044cd716d83d3c1 (patch)
tree42f0f24716575e7491f71a9c7fd90bb32eb560fd
parentc1db00cc3c2c6f3a0c3ce74a7dff37b9e4c7bf4b (diff)
downloadbugzilla-df48c469975515876988677ed044cd716d83d3c1.tar.gz
bugzilla-df48c469975515876988677ed044cd716d83d3c1.tar.xz
Patch for bug 269398: request.cgi should not fail with error in SQL when no products are available for the user; patch by Frédéric Buclin <LpSolit@netscape.net>, r=vladd, a=justdave.
-rw-r--r--globals.pl26
1 files changed, 14 insertions, 12 deletions
diff --git a/globals.pl b/globals.pl
index 677047fe2..02a4f8fb4 100644
--- a/globals.pl
+++ b/globals.pl
@@ -634,21 +634,23 @@ sub GetSelectableProductHash {
PushGlobalSQLState();
foreach my $table (@tables) {
- # Why oh why can't we standardize on these names?!?
- my $fld = ($table eq "components" ? "name" : "value");
-
- my $query = "SELECT $fld, product_id FROM $table WHERE product_id IN " .
- "(" . join(",", keys %products) . ") ORDER BY $fld";
- SendSQL($query);
-
my %values;
my %values_by_product;
- while (MoreSQLData()) {
- my ($name, $product_id) = FetchSQLData();
- next unless $name;
- $values{$name} = 1;
- push @{$values_by_product{$products{$product_id}}}, $name;
+ if (scalar(keys %products)) {
+ # Why oh why can't we standardize on these names?!?
+ my $fld = ($table eq "components" ? "name" : "value");
+
+ my $query = "SELECT $fld, product_id FROM $table WHERE product_id " .
+ "IN (" . join(",", keys %products) . ") ORDER BY $fld";
+ SendSQL($query);
+
+ while (MoreSQLData()) {
+ my ($name, $product_id) = FetchSQLData();
+ next unless $name;
+ $values{$name} = 1;
+ push @{$values_by_product{$products{$product_id}}}, $name;
+ }
}
$selectables->{"legal_$table"} = [sort keys %values];