From: jocuri%softhome.net <> Date: Sat, 11 Dec 2004 08:05:03 +0000 (+0000) Subject: Patch for bug 269398: request.cgi should not fail with error in SQL when no products... X-Git-Tag: bugzilla-2.18~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1dee35efd069a701123be9cf4f6f248d5ad42a95;p=thirdparty%2Fbugzilla.git 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 , r=vladd, a=justdave. --- diff --git a/globals.pl b/globals.pl index 55e4907f8b..214ae396e4 100644 --- a/globals.pl +++ b/globals.pl @@ -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];