]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Patch for bug 269398: request.cgi should not fail with error in SQL when no products...
authorjocuri%softhome.net <>
Sat, 11 Dec 2004 08:05:03 +0000 (08:05 +0000)
committerjocuri%softhome.net <>
Sat, 11 Dec 2004 08:05:03 +0000 (08:05 +0000)
globals.pl

index 55e4907f8b6bbf40c57e101982614c9a39e11594..214ae396e487005d90d102034e55b75c965086f8 100644 (file)
@@ -584,21 +584,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];