diff options
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/TrackingFlags/Extension.pm | 15 | ||||
-rw-r--r-- | extensions/TrackingFlags/lib/Flag.pm | 10 | ||||
-rw-r--r-- | extensions/TrackingFlags/lib/Flag/Value.pm | 7 |
3 files changed, 30 insertions, 2 deletions
diff --git a/extensions/TrackingFlags/Extension.pm b/extensions/TrackingFlags/Extension.pm index b150faea2..08e7968a0 100644 --- a/extensions/TrackingFlags/Extension.pm +++ b/extensions/TrackingFlags/Extension.pm @@ -29,6 +29,7 @@ use JSON; use List::MoreUtils qw(none); our $VERSION = '1'; +our @FLAG_CACHE; BEGIN { *Bugzilla::tracking_flags = \&_tracking_flags; @@ -552,6 +553,20 @@ sub _tracking_flags_search_nonchanged { } } +sub request_cleanup { + foreach my $flag (@FLAG_CACHE) { + my $bug_flag = delete $flag->{bug_flag}; + if ($bug_flag) { + delete $bug_flag->{bug}; + delete $bug_flag->{tracking_flag}; + } + foreach my $value (@{ $flag->{values} }) { + delete $value->{tracking_flag}; + } + } + @FLAG_CACHE = (); +} + sub bug_end_of_create { my ($self, $args) = @_; my $bug = $args->{'bug'}; diff --git a/extensions/TrackingFlags/lib/Flag.pm b/extensions/TrackingFlags/lib/Flag.pm index cfda0bad5..7b6effa98 100644 --- a/extensions/TrackingFlags/lib/Flag.pm +++ b/extensions/TrackingFlags/lib/Flag.pm @@ -87,6 +87,16 @@ sub new { return $class->SUPER::new($param); } +sub new_from_hash { + my $class = shift; + my $cache = Bugzilla->request_cache->{'tracking_flags'} //= {}; + my $flag = $class->SUPER::new_from_hash(@_); + if ($flag) { + push @Bugzilla::Extension::TrackingFlags::FLAG_CACHE, $flag; + } + return $flag; +} + sub create { my $class = shift; my $params = shift; diff --git a/extensions/TrackingFlags/lib/Flag/Value.pm b/extensions/TrackingFlags/lib/Flag/Value.pm index 964d76810..15be61bc7 100644 --- a/extensions/TrackingFlags/lib/Flag/Value.pm +++ b/extensions/TrackingFlags/lib/Flag/Value.pm @@ -15,7 +15,7 @@ use warnings; use Bugzilla::Error; use Bugzilla::Group; use Bugzilla::Util qw(detaint_natural trim); -use Scalar::Util qw(blessed); +use Scalar::Util qw(blessed weaken); ############################### #### Initialization #### @@ -118,9 +118,12 @@ sub is_active { return $_[0]->{'is_active'}; } sub comment { return $_[0]->{'comment'}; } sub tracking_flag { - return $_[0]->{'tracking_flag'} ||= Bugzilla::Extension::TrackingFlags::Flag->new({ + return $_[0]->{'tracking_flag'} if $_[0]->{'tracking_flag'}; + my $tf = $_[0]->{'tracking_flag'} = Bugzilla::Extension::TrackingFlags::Flag->new({ id => $_[0]->tracking_flag_id, cache => 1 }); + weaken($_[0]->{'tracking_flag'}); + return $tf; } sub setter_group { |