$comment->{count} = $count++;
$comment->{bug} = $self;
}
+ Bugzilla::Comment->preload($self->{'comments'});
}
my @comments = @{ $self->{'comments'} };
use Bugzilla::Attachment;
use Bugzilla::Constants;
use Bugzilla::Error;
+use Bugzilla::User;
use Bugzilla::Util;
###############################
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 ######
###############################