]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1053513 - remove last-visited entries when a user removes involvement from a bug
authorDylan William Hardison <dylan@hardison.net>
Tue, 9 Sep 2014 20:32:40 +0000 (16:32 -0400)
committerDylan William Hardison <dylan@hardison.net>
Tue, 9 Sep 2014 20:32:40 +0000 (16:32 -0400)
r/a=glob

Bugzilla/Bug.pm
Bugzilla/BugUserLastVisit.pm

index d03c63768b027c2fc1dee6d373b569b87c10c86d..223ca1ae003e82aa4407178452ff11066d51d44c 100644 (file)
@@ -1134,6 +1134,13 @@ sub update {
         $self->update_user_last_visit($user, $delta_ts);
     }
 
+    # If a user is no longer involved, remove their last visit entry
+    my $last_visits =
+      Bugzilla::BugUserLastVisit->match({ bug_id => $self->id });
+    foreach my $lv (@$last_visits) {
+        $lv->remove_from_db() unless $lv->user->is_involved_with_bug($self);
+    }
+
     # Update bug ignore data if user wants to ignore mail for this bug
     if (exists $self->{'bug_ignored'}) {
         my $bug_ignored_changed;
index 9c7dcd452f6776fcb7cb735aa6648a4edfbb3d88..d043b121abddefcd45e0a74b62b3fd021d162afc 100644 (file)
@@ -39,6 +39,13 @@ sub bug_id        { return $_[0]->{bug_id}        }
 sub user_id       { return $_[0]->{user_id}       }
 sub last_visit_ts { return $_[0]->{last_visit_ts} }
 
+sub user {
+    my $self = shift;
+
+    $self->{user} //= Bugzilla::User->new({ id => $self->user_id, cache => 1 });
+    return $self->{user};
+}
+
 1;
 __END__
 
@@ -81,4 +88,6 @@ listed below.
 
 =item C<last_visit_ts>
 
+=item C<user>
+
 =back