Commit 75e92404 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 428440: Move code to set new product and related groups from process_bug.cgi…

Bug 428440: Move code to set new product and related groups from process_bug.cgi to new function $bug->set_all - Patch by Noura Elhawary <nelhawar@redhat.com> r=LpSolit r=mkanat a=mkanat
parent d97a8e06
...@@ -501,6 +501,33 @@ sub run_create_validators { ...@@ -501,6 +501,33 @@ sub run_create_validators {
return $params; return $params;
} }
sub set_all {
my ($self, $args) = @_;
# For security purposes, and because lots of other checks depend on it,
# we set the product first before anything else.
my $product_change = 0;
if ($args->{product}) {
my $changed = $self->set_product($args->{product},
{ component => $args->{component},
version => $args->{version},
target_milestone => $args->{target_milestone},
change_confirmed => $args->{confirm_product_change},
other_bugs => $args->{other_bugs},
});
# that will be used later to check strict isolation
$product_change = $changed;
}
# add/remove groups
$self->remove_group($_) foreach @{$args->{remove_group}};
$self->add_group($_) foreach @{$args->{add_group}};
# this is temporary until all related code is moved from
# process_bug.cgi to set_all
return $product_change;
}
sub update { sub update {
my $self = shift; my $self = shift;
......
...@@ -241,39 +241,36 @@ foreach my $bug (@bug_objects) { ...@@ -241,39 +241,36 @@ foreach my $bug (@bug_objects) {
} }
} }
# For security purposes, and because lots of other checks depend on it, my $product_change;
# we set the product first before anything else. foreach my $bug (@bug_objects) {
my $product_change; # Used only for strict_isolation checks, right now. my $args;
if (should_set('product')) { if (should_set('product')) {
foreach my $b (@bug_objects) { $args->{product} = scalar $cgi->param('product');
my $changed = $b->set_product(scalar $cgi->param('product'), $args->{component} = scalar $cgi->param('component');
{ component => scalar $cgi->param('component'), $args->{version} = scalar $cgi->param('version');
version => scalar $cgi->param('version'), $args->{target_milestone} = scalar $cgi->param('target_milestone');
target_milestone => scalar $cgi->param('target_milestone'), $args->{confirm_product_change} = scalar $cgi->param('confirm_product_change');
change_confirmed => scalar $cgi->param('confirm_product_change'), $args->{other_bugs} = \@bug_objects;
other_bugs => \@bug_objects,
});
$product_change ||= $changed;
} }
}
foreach my $group (@{$bug->product_obj->groups_valid}) {
# strict_isolation checks mean that we should set the groups
# immediately after changing the product.
foreach my $b (@bug_objects) {
foreach my $group (@{$b->product_obj->groups_valid}) {
my $gid = $group->id; my $gid = $group->id;
if (should_set("bit-$gid", 1)) { if (should_set("bit-$gid", 1)) {
# Check ! first to avoid having to check defined below. # Check ! first to avoid having to check defined below.
if (!$cgi->param("bit-$gid")) { if (!$cgi->param("bit-$gid")) {
$b->remove_group($gid); push (@{$args->{remove_group}}, $gid);
} }
# "== 1" is important because mass-change uses -1 to mean # "== 1" is important because mass-change uses -1 to mean
# "don't change this restriction" # "don't change this restriction"
elsif ($cgi->param("bit-$gid") == 1) { elsif ($cgi->param("bit-$gid") == 1) {
$b->add_group($gid); push (@{$args->{add_group}}, $gid);
} }
} }
} }
# this will be deleted later when code moves to $bug->set_all
my $changed = $bug->set_all($args);
$product_change ||= $changed;
} }
if ($cgi->param('id') && (defined $cgi->param('dependson') if ($cgi->param('id') && (defined $cgi->param('dependson')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment