diff options
Diffstat (limited to 'Bugzilla/Comment.pm')
-rw-r--r-- | Bugzilla/Comment.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index d995d4509..2f063934a 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -21,7 +21,7 @@ use Bugzilla::User; use Bugzilla::Util; use List::Util qw(first); -use Scalar::Util qw(blessed); +use Scalar::Util qw(blessed weaken isweak); ############################### #### Initialization #### @@ -232,8 +232,11 @@ sub collapsed { sub bug { my $self = shift; require Bugzilla::Bug; - $self->{bug} ||= new Bugzilla::Bug($self->bug_id); - return $self->{bug}; + + # note $bug exists as a strong reference to keep $self->{bug} defined until the end of this method + my $bug = $self->{bug} ||= new Bugzilla::Bug($self->bug_id); + weaken($self->{bug}) unless isweak($self->{bug}); + return $bug; } sub is_about_attachment { |