From: Dylan William Hardison Date: Tue, 9 Sep 2014 20:32:40 +0000 (-0400) Subject: Bug 1053513 - remove last-visited entries when a user removes involvement from a bug X-Git-Tag: bugzilla-4.5.6~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=961fb4f72ecf393bcac58d69da1ac1509413179e;p=thirdparty%2Fbugzilla.git Bug 1053513 - remove last-visited entries when a user removes involvement from a bug r/a=glob --- diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index d03c63768b..223ca1ae00 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -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; diff --git a/Bugzilla/BugUserLastVisit.pm b/Bugzilla/BugUserLastVisit.pm index 9c7dcd452f..d043b121ab 100644 --- a/Bugzilla/BugUserLastVisit.pm +++ b/Bugzilla/BugUserLastVisit.pm @@ -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 +=item C + =back