From 1dee35efd069a701123be9cf4f6f248d5ad42a95 Mon Sep 17 00:00:00 2001 From: "jocuri%softhome.net" <> Date: Sat, 11 Dec 2004 08:05:03 +0000 Subject: [PATCH] =?utf8?q?Patch=20for=20bug=20269398:=20request.cgi=20shou?= =?utf8?q?ld=20not=20fail=20with=20error=20in=20SQL=20when=20no=20products?= =?utf8?q?=20are=20available=20for=20the=20user;=20patch=20by=20Fr=C3=A9d?= =?utf8?q?=C3=A9ric=20Buclin=20,=20r=3Dvladd,=20a=3D?= =?utf8?q?justdave.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- globals.pl | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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]; -- 2.47.2