summaryrefslogtreecommitdiffstats
path: root/editflagtypes.cgi
diff options
context:
space:
mode:
authorlpsolit%gmail.com <>2006-06-18 08:12:35 +0200
committerlpsolit%gmail.com <>2006-06-18 08:12:35 +0200
commit0d2869cdc8bf59db57e80e7e3a0c0c377fc0ffb5 (patch)
tree03ab21ba894bffea01fb977c93b4ede6f553742f /editflagtypes.cgi
parentd9548f66b0f47af651f8fa62fa69cc7e65df0a60 (diff)
downloadbugzilla-0d2869cdc8bf59db57e80e7e3a0c0c377fc0ffb5.tar.gz
bugzilla-0d2869cdc8bf59db57e80e7e3a0c0c377fc0ffb5.tar.xz
Bug 338796: Remove get_product_* from globals.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=wicked a=justdave
Diffstat (limited to 'editflagtypes.cgi')
-rwxr-xr-xeditflagtypes.cgi28
1 files changed, 19 insertions, 9 deletions
diff --git a/editflagtypes.cgi b/editflagtypes.cgi
index 822f00744..e055e9d9d 100755
--- a/editflagtypes.cgi
+++ b/editflagtypes.cgi
@@ -278,15 +278,20 @@ sub processCategoryChange {
sub clusion_array_to_hash {
my $array = shift;
my %hash;
+ my %products;
my %components;
foreach my $ids (@$array) {
trick_taint($ids);
my ($product_id, $component_id) = split(":", $ids);
- my $product_name = get_product_name($product_id) || "__Any__";
+ my $product_name = "__Any__";
+ if ($product_id) {
+ $products{$product_id} ||= new Bugzilla::Product($product_id);
+ $product_name = $products{$product_id}->name if $products{$product_id};
+ }
my $component_name = "__Any__";
if ($component_id) {
$components{$component_id} ||= new Bugzilla::Component($component_id);
- $component_name = $components{$component_id}->name;
+ $component_name = $components{$component_id}->name if $components{$component_id};
}
$hash{"$product_name:$component_name"} = $ids;
}
@@ -656,6 +661,8 @@ sub validateAndSubmit {
my ($id) = @_;
my $dbh = Bugzilla->dbh;
+ # Cache product objects.
+ my %products;
foreach my $category_type ("inclusions", "exclusions") {
# Will be used several times below.
my $sth = $dbh->prepare("INSERT INTO flag$category_type " .
@@ -666,15 +673,18 @@ sub validateAndSubmit {
foreach my $category ($cgi->param($category_type)) {
trick_taint($category);
my ($product_id, $component_id) = split(":", $category);
- # The product does not exist.
- next if ($product_id && !get_product_name($product_id));
+ # Does the product exist?
+ if ($product_id) {
+ $products{$product_id} ||= new Bugzilla::Product($product_id);
+ next unless defined $products{$product_id};
+ }
# A component was selected without a product being selected.
next if (!$product_id && $component_id);
- # The component does not belong to this product.
- next if ($component_id
- && !$dbh->selectrow_array("SELECT id FROM components
- WHERE id = ? AND product_id = ?",
- undef, ($component_id, $product_id)));
+ # Does the component belong to this product?
+ if ($component_id) {
+ my @match = grep {$_->id == $component_id} @{$products{$product_id}->components};
+ next unless scalar(@match);
+ }
$product_id ||= undef;
$component_id ||= undef;
$sth->execute($id, $product_id, $component_id);