diff options
Diffstat (limited to 'Bugzilla/Comment.pm')
-rw-r--r-- | Bugzilla/Comment.pm | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Bugzilla/Comment.pm b/Bugzilla/Comment.pm index f19c64d78..ba33ba5f3 100644 --- a/Bugzilla/Comment.pm +++ b/Bugzilla/Comment.pm @@ -27,6 +27,7 @@ use base qw(Bugzilla::Object); use Bugzilla::Attachment; use Bugzilla::Constants; use Bugzilla::Error; +use Bugzilla::User; use Bugzilla::Util; ############################### @@ -74,6 +75,18 @@ sub update { return $changes; } +# Speeds up displays of comment lists by loading all ->author objects +# at once for a whole list. +sub preload { + my ($class, $comments) = @_; + my %user_ids = map { $_->{who} => 1 } @$comments; + my $users = Bugzilla::User->new_from_list([keys %user_ids]); + my %user_map = map { $_->id => $_ } @$users; + foreach my $comment (@$comments) { + $comment->{author} = $user_map{$comment->{who}}; + } +} + ############################### #### Accessors ###### ############################### |