From 670ea222ff6b4e7b1d544c939972a7252665e3fc Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Thu, 1 Mar 2012 23:24:08 +0100 Subject: Bug 731562: Cache the global/user.html.tmpl template for improved performance r=dkl a=LpSolit --- Bugzilla/Template.pm | 10 +++++++++- Bugzilla/User.pm | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index dcbe37b3f..78c537cc3 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -912,7 +912,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 bda055af4..5462b33db 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -774,6 +774,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->groups }; + return \@groups; +} + sub get_products_by_permission { my ($self, $group) = @_; # Make sure $group exists on a per-product basis. -- cgit v1.2.3-24-g4f1b