diff options
author | Dylan Hardison <dylan@mozilla.com> | 2016-07-04 23:36:58 +0200 |
---|---|---|
committer | Dylan Hardison <dylan@mozilla.com> | 2016-07-04 23:36:58 +0200 |
commit | 9a15297a823443b19661211293bb79e7f42a44e3 (patch) | |
tree | 6201a329e16964b86f74a8c152e3b63d66c7339f /extensions/TrackingFlags/lib | |
parent | 3bf65ba172080fbed1e7d4e285075fa67de73fed (diff) | |
download | bugzilla-9a15297a823443b19661211293bb79e7f42a44e3.tar.gz bugzilla-9a15297a823443b19661211293bb79e7f42a44e3.tar.xz |
Bug 1282606 - Fix TrackingFlags memory leak
Diffstat (limited to 'extensions/TrackingFlags/lib')
-rw-r--r-- | extensions/TrackingFlags/lib/Flag.pm | 10 | ||||
-rw-r--r-- | extensions/TrackingFlags/lib/Flag/Value.pm | 7 |
2 files changed, 15 insertions, 2 deletions
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 { |