diff options
-rw-r--r-- | Bugzilla/Bug.pm | 12 | ||||
-rwxr-xr-x | process_bug.cgi | 52 |
2 files changed, 38 insertions, 26 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 26e71c4f8..6f2c2b602 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1854,6 +1854,15 @@ sub set_all { my $self = shift; my ($params) = @_; + # strict_isolation checks mean that we should set the groups + # immediately after changing the product. + foreach my $group (@{ $params->{groups}->{add} || [] }) { + $self->add_group($group); + } + foreach my $group (@{ $params->{groups}->{remove} || [] }) { + $self->remove_group($group); + } + if (exists $params->{'dependson'} or exists $params->{'blocked'}) { my %set_deps; foreach my $name (qw(dependson blocked)) { @@ -2400,7 +2409,8 @@ sub add_group { # to this group by the current user. $self->product_obj->group_is_settable($group) || ThrowUserError('group_invalid_restriction', - { product => $self->product, group_id => $group->id }); + { product => $self->product, group_id => $group->id, + bug => $self }); # OtherControl people can add groups only during a product change, # and only when the group is not NA for them. diff --git a/process_bug.cgi b/process_bug.cgi index bac09450f..63fc3209b 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -255,31 +255,6 @@ if (should_set('product')) { } } -# 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; - if (should_set("bit-$gid", 1)) { - # Check ! first to avoid having to check defined below. - if (!$cgi->param("bit-$gid")) { - $b->remove_group($gid); - } - # "== 1" is important because mass-change uses -1 to mean - # "don't change this restriction" - elsif ($cgi->param("bit-$gid") == 1) { - $b->add_group($gid); - } - } - } -} - -# Flags should be set AFTER the bug has been moved into another product/component. -if ($cgi->param('id')) { - my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi($first_bug, undef, $vars); - $first_bug->set_flags($flags, $new_flags); -} - # Component, target_milestone, and version are in here just in case # the 'product' field wasn't defined in the CGI. It doesn't hurt to set # them twice. @@ -333,6 +308,27 @@ foreach my $dep_field (qw(dependson blocked)) { } } } +my %groups = ( add => [], remove => [] ); +my %checked_bit; # Used to avoid adding groups twice (defined_ + actual bit-) +foreach my $param_name (grep(/bit-\d+$/, $cgi->param())) { + $param_name =~ /bit-(\d+)$/; + my $gid = $1; + next if $checked_bit{$gid}; + my $bit_param = "bit-$gid"; + if (should_set($bit_param, 1)) { + # Check ! first to avoid having to check defined below. + if (!$cgi->param($bit_param)) { + push(@{ $groups{remove} }, $gid); + } + # "== 1" is important because mass-change uses -1 to mean + # "don't change this restriction" + elsif ($cgi->param($bit_param) == 1) { + push(@{ $groups{add} }, $gid); + } + } + $checked_bit{$gid} = 1; +} +$set_all_fields{groups} = \%groups; my @custom_fields = Bugzilla->active_custom_fields; foreach my $field (@custom_fields) { @@ -348,6 +344,12 @@ foreach my $b (@bug_objects) { # Certain changes can only happen on individual bugs, never on mass-changes. if (defined $cgi->param('id')) { + # Flags should be set AFTER the bug has been moved into another + # product/component. + my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi( + $first_bug, undef, $vars); + $first_bug->set_flags($flags, $new_flags); + # Since aliases are unique (like bug numbers), they can only be changed # for one bug at a time. if (Bugzilla->params->{"usebugaliases"} && defined $cgi->param('alias')) { |