Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
670ea222
Commit
670ea222
authored
Mar 01, 2012
by
Frédéric Buclin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 731562: Cache the global/user.html.tmpl template for improved performance
r=dkl a=LpSolit
parent
2e3a5735
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
2 deletions
+34
-2
Template.pm
Bugzilla/Template.pm
+8
-0
User.pm
Bugzilla/User.pm
+9
-0
list.html.tmpl
template/en/default/attachment/list.html.tmpl
+8
-0
comments.html.tmpl
template/en/default/bug/comments.html.tmpl
+9
-2
No files found.
Bugzilla/Template.pm
View file @
670ea222
...
@@ -913,6 +913,14 @@ sub create {
...
@@ -913,6 +913,14 @@ sub create {
return
$cache
->
{
template_bug_fields
};
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
,
'css_files'
=>
\&
css_files
,
yui_resolve_deps
=>
\&
yui_resolve_deps
,
yui_resolve_deps
=>
\&
yui_resolve_deps
,
...
...
Bugzilla/User.pm
View file @
670ea222
...
@@ -774,6 +774,15 @@ sub in_group_id {
...
@@ -774,6 +774,15 @@ sub in_group_id {
return
grep
(
$_
->
id
==
$id
,
@
{
$self
->
groups
})
?
1
:
0
;
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
{
sub
get_products_by_permission
{
my
(
$self
,
$group
)
=
@_
;
my
(
$self
,
$group
)
=
@_
;
# Make sure $group exists on a per-product basis.
# Make sure $group exists on a per-product basis.
...
...
template/en/default/attachment/list.html.tmpl
View file @
670ea222
...
@@ -51,6 +51,7 @@ function toggle_display(link) {
...
@@ -51,6 +51,7 @@ function toggle_display(link) {
[% count = 0 %]
[% count = 0 %]
[% obsolete_attachments = 0 %]
[% obsolete_attachments = 0 %]
[% user_cache = template_cache.users %]
[% FOREACH attachment = attachments %]
[% FOREACH attachment = attachments %]
[% count = count + 1 %]
[% count = count + 1 %]
...
@@ -89,7 +90,14 @@ function toggle_display(link) {
...
@@ -89,7 +90,14 @@ function toggle_display(link) {
title="Go to the comment associated with the attachment">
title="Go to the comment associated with the attachment">
[%- attachment.attached FILTER time %]</a>,
[%- attachment.attached FILTER time %]</a>,
[%# 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 %]
[% INCLUDE global/user.html.tmpl who = attachment.attacher %]
[% END %]
[% END %]
[% user_cache.$attacher_id FILTER none %]
</span>
</span>
</td>
</td>
...
...
template/en/default/bug/comments.html.tmpl
View file @
670ea222
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
[% DEFAULT start_at = 0 mode = "show" %]
[% DEFAULT start_at = 0 mode = "show" %]
[% sort_order = user.settings.comment_sort_order.value %]
[% 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,
[%# 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.
# in which case we don't care what the user's preference is.
...
@@ -170,12 +171,18 @@
...
@@ -170,12 +171,18 @@
</span>
</span>
<span class="bz_comment_user">
<span class="bz_comment_user">
[%# 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 %]
[% INCLUDE global/user.html.tmpl who = comment.author %]
[% END %]
[% END %]
[% user_cache.$commenter_id FILTER none %]
</span>
</span>
<span class="bz_comment_user_images">
<span class="bz_comment_user_images">
[% FOREACH group = comment.author.groups %]
[% FOREACH group = comment.author.groups_with_icon %]
[% NEXT UNLESS group.icon_url %]
<img src="[% group.icon_url FILTER html %]"
<img src="[% group.icon_url FILTER html %]"
alt="[% group.name FILTER html %]"
alt="[% group.name FILTER html %]"
title="[% group.name FILTER html %] - [% group.description FILTER html %]">
title="[% group.name FILTER html %] - [% group.description FILTER html %]">
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment