summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Bug.pm
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-16 06:37:38 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-03-16 06:37:38 +0100
commit0ee52e9d7d307d6ceed73a53de1a64589bb79f62 (patch)
treeb87ab5aa07f80448a970062bb7b9866971dd0ae3 /Bugzilla/Bug.pm
parent1175447aedff9bffccb7733d16a4934448a1a7fe (diff)
downloadbugzilla-0ee52e9d7d307d6ceed73a53de1a64589bb79f62.tar.gz
bugzilla-0ee52e9d7d307d6ceed73a53de1a64589bb79f62.tar.xz
Bug 526189: Refactor the way that groups are checked for being validly
settable in a particular product, to eliminate the possibility of ever setting an inactive or invalid group on a product. r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/Bug.pm')
-rw-r--r--Bugzilla/Bug.pm21
1 files changed, 11 insertions, 10 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index d435d5442..9282bc3d2 100644
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -1410,7 +1410,7 @@ sub _check_groups {
# so instead of doing check(), we just do "next" on an invalid
# group.
my $group = new Bugzilla::Group({ name => $name }) or next;
- next if !$product->group_is_valid($group);
+ next if !$product->group_is_settable($group);
$add_groups{$group->id} = $group;
}
}
@@ -2074,15 +2074,14 @@ sub set_product {
}
if ($product_changed) {
- # Remove groups that aren't valid in the new product. This will also
- # have the side effect of removing the bug from groups that aren't
- # active anymore.
+ # Remove groups that can't be set in the new product, or that aren't
+ # active.
#
# We copy this array because the original array is modified while we're
# working, and that confuses "foreach".
my @current_groups = @{$self->groups_in};
foreach my $group (@current_groups) {
- if (!grep($group->id == $_->id, @{$product->groups_valid})) {
+ if (!$group->is_active or !$product->group_is_valid($group)) {
$self->remove_group($group);
}
}
@@ -2326,8 +2325,8 @@ sub add_group {
return if !$group->is_active or !$group->is_bug_group;
# Make sure that bugs in this product can actually be restricted
- # to this group.
- grep($group->id == $_->id, @{$self->product_obj->groups_valid})
+ # 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 });
@@ -2355,12 +2354,14 @@ sub remove_group {
return unless $group;
# First, check if this is a valid group for this product.
- # You can *always* remove a group that is not valid for this product, so
- # we don't do any other checks if that's the case. (set_product does this.)
+ # You can *always* remove a group that is not valid for this product
+ # or that is not active, so we don't do any other checks if either of
+ # those are the case. (Users might remove inactive groups, and set_product
+ # removes groups that aren't valid for this product.)
#
# This particularly happens when isbuggroup is no longer 1, and we're
# moving a bug to a new product.
- if (grep($_->id == $group->id, @{$self->product_obj->groups_valid})) {
+ if ($group->is_active and $self->product_obj->group_is_valid($group)) {
my $controls = $self->product_obj->group_controls->{$group->id};
# Nobody can ever remove a Mandatory group.