summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Bugzilla/Template.pm10
-rw-r--r--Bugzilla/User.pm9
-rw-r--r--template/en/default/attachment/list.html.tmpl10
-rw-r--r--template/en/default/bug/comments.html.tmpl16
4 files changed, 38 insertions, 7 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index a1a6944f0..f069b19d2 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -938,7 +938,15 @@ sub create {
Bugzilla->fields({ by_name => 1 });
return $cache->{template_bug_fields};
},
-
+
+ # A general purpose cache to store rendered templates for reuse.
+ # Make sure to not mix language-specific data.
+ 'template_cache' => sub {
+ my $cache = Bugzilla->request_cache->{template_cache} ||= {};
+ $cache->{users} ||= {};
+ return $cache;
+ },
+
'css_files' => \&css_files,
yui_resolve_deps => \&yui_resolve_deps,
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index d6e343429..e9d2754f7 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -779,6 +779,15 @@ sub in_group_id {
return grep($_->id == $id, @{ $self->groups }) ? 1 : 0;
}
+# This is a helper to get all groups which have an icon to be displayed
+# besides the name of the commenter.
+sub groups_with_icon {
+ my $self = shift;
+
+ my @groups = grep { $_->icon_url } @{ $self->direct_group_membership };
+ return \@groups;
+}
+
sub get_products_by_permission {
my ($self, $group) = @_;
# Make sure $group exists on a per-product basis.
diff --git a/template/en/default/attachment/list.html.tmpl b/template/en/default/attachment/list.html.tmpl
index fa8e4774e..5079a0eec 100644
--- a/template/en/default/attachment/list.html.tmpl
+++ b/template/en/default/attachment/list.html.tmpl
@@ -64,6 +64,7 @@ function toggle_display(link) {
[% count = 0 %]
[% obsolete_attachments = 0 %]
+ [% user_cache = template_cache.users %]
[% FOREACH attachment = attachments %]
[% count = count + 1 %]
@@ -102,7 +103,14 @@ function toggle_display(link) {
title="Go to the comment associated with the attachment">
[%- attachment.attached FILTER time %]</a>,
- [% INCLUDE global/user.html.tmpl who = attachment.attacher %]
+ [%# No need to recreate the exact same template if we already have it. %]
+ [% attacher_id = attachment.attacher.id %]
+ [% UNLESS user_cache.$attacher_id %]
+ [% user_cache.$attacher_id = BLOCK %]
+ [% INCLUDE global/user.html.tmpl who = attachment.attacher %]
+ [% END %]
+ [% END %]
+ [% user_cache.$attacher_id FILTER none %]
</span>
</td>
diff --git a/template/en/default/bug/comments.html.tmpl b/template/en/default/bug/comments.html.tmpl
index 2a00b47ec..3c303afb8 100644
--- a/template/en/default/bug/comments.html.tmpl
+++ b/template/en/default/bug/comments.html.tmpl
@@ -63,6 +63,7 @@
[% DEFAULT start_at = 0 mode = "show" %]
[% sort_order = user.settings.comment_sort_order.value %]
+[% user_cache = template_cache.users %]
[%# NOTE: (start_at > 0) means we came here from a midair collision,
# in which case we don't care what the user's preference is.
@@ -176,13 +177,18 @@
</span>
<span class="bz_comment_user">
- [% INCLUDE global/user.html.tmpl who = comment.author %]
- [% Hook.process('user', 'bug/comments.html.tmpl') %]
- </span>
+ [%# No need to recreate the exact same template if we already have it. %]
+ [% commenter_id = comment.author.id %]
+ [% UNLESS user_cache.$commenter_id %]
+ [% user_cache.$commenter_id = BLOCK %]
+ [% INCLUDE global/user.html.tmpl who = comment.author %]
+ [% END %]
+ [% END %]
+ [% user_cache.$commenter_id FILTER none %]
+ </span>
<span class="bz_comment_user_images">
- [% FOREACH group = comment.author.direct_group_membership %]
- [% NEXT UNLESS group.icon_url %]
+ [% FOREACH group = comment.author.groups_with_icon %]
<img src="[% group.icon_url FILTER html %]"
alt="[% group.name FILTER html %]"
title="[% group.name FILTER html %] - [% group.description FILTER html %]">