]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1261124: When deleting a component, this component is listed again
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 5 Apr 2016 15:22:25 +0000 (17:22 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 5 Apr 2016 15:22:25 +0000 (17:22 +0200)
r/a=dkl

Bugzilla/Component.pm

index 9bc0a449314f9edd54228c3af7df77a04c9de62b..d5a6ece5de87860bf506555e69b5bb8c35e5ca46 100644 (file)
@@ -148,7 +148,8 @@ sub remove_from_db {
     $dbh->bz_start_transaction();
 
     # Products must have at least one component.
-    if (scalar(@{$self->product->components}) == 1) {
+    my @components = @{ $self->product->components };
+    if (scalar(@components) == 1) {
         ThrowUserError('component_is_last', { comp => $self });
     }
 
@@ -165,6 +166,8 @@ sub remove_from_db {
             ThrowUserError('component_has_bugs', {nb => $self->bug_count});
         }
     }
+    # Update the list of components in the product object.
+    $self->product->{components} = [grep { $_->id != $self->id } @components];
     $self->SUPER::remove_from_db();
 
     $dbh->bz_commit_transaction();