summaryrefslogtreecommitdiffstats
path: root/extensions/TrackingFlags/lib
diff options
context:
space:
mode:
authorDylan Hardison <dylan@mozilla.com>2016-07-04 23:36:58 +0200
committerDylan Hardison <dylan@mozilla.com>2016-07-04 23:36:58 +0200
commit9a15297a823443b19661211293bb79e7f42a44e3 (patch)
tree6201a329e16964b86f74a8c152e3b63d66c7339f /extensions/TrackingFlags/lib
parent3bf65ba172080fbed1e7d4e285075fa67de73fed (diff)
downloadbugzilla-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.pm10
-rw-r--r--extensions/TrackingFlags/lib/Flag/Value.pm7
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 {