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
217beee4
Commit
217beee4
authored
Mar 13, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 498309: Speed up show_bug.cgi when there are many comments by caching
field-descs globally for all template calls r=LpSolit, a=LpSolit
parent
f276a11f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
75 deletions
+118
-75
Template.pm
Bugzilla/Template.pm
+6
-1
Util.pm
Bugzilla/Util.pm
+29
-1
field-descs-end.none.tmpl
...template/en/default/hook/global/field-descs-end.none.tmpl
+3
-2
field-descs.none.tmpl
template/en/default/global/field-descs.none.tmpl
+80
-71
No files found.
Bugzilla/Template.pm
View file @
217beee4
...
...
@@ -236,7 +236,7 @@ sub quoteUrls {
# we have to do this in one pattern, and so this is semi-messy.
# Also, we can't use $bug_re?$comment_re? because that will match the
# empty string
my $bug_word =
get_text('term', { term => 'bug' })
;
my $bug_word =
template_var('terms')->{bug}
;
my $bug_re = qr/\Q$bug_word\E\s*\#?\s*(\d+)/i;
my $comment_re = qr/comment\s*\#?\s*(\d+)/i;
$text =~ s~\b($bug_re(?:\s*,?\s*$comment_re)?|$comment_re)
...
...
@@ -774,6 +774,11 @@ sub create {
'feature_enabled'
=>
sub
{
return
Bugzilla
->
feature
(
@_
);
},
# field_descs can be somewhat slow to generate, so we generate
# it only once per-language no matter how many times
# $template->process() is called.
'field_descs'
=>
sub
{
return
template_var
(
'field_descs'
)
},
'install_string'
=>
\&
Bugzilla::Install::Util::
install_string
,
# These don't work as normal constants.
...
...
Bugzilla/Util.pm
View file @
217beee4
...
...
@@ -44,7 +44,7 @@ use base qw(Exporter);
file_mod_time is_7bit_clean
bz_crypt generate_random_password
validate_email_syntax clean_text
get_text disable_utf8)
;
get_text
template_var
disable_utf8)
;
use
Bugzilla::
Constants
;
...
...
@@ -621,6 +621,26 @@ sub get_text {
return
$message
;
}
sub
template_var
{
my
$name
=
shift
;
my
$cache
=
Bugzilla
->
request_cache
->
{
util_template_var
}
||=
{};
my
$template
=
Bugzilla
->
template_inner
;
my
$lang
=
$template
->
context
->
{
bz_language
};
return
$cache
->
{
$lang
}
->
{
$name
}
if
defined
$cache
->
{
$lang
};
my
%
vars
;
# Note: If we suddenly start needing a lot of template_var variables,
# they should move into their own template, not field-descs.
my
$result
=
$template
->
process
(
'global/field-descs.none.tmpl'
,
{
vars
=>
\%
vars
,
in_template_var
=>
1
});
# Bugzilla::Error can't be "use"d in Bugzilla::Util.
if
(
!
$result
)
{
require
Bugzilla::
Error
;
Bugzilla::Error::
ThrowTemplateError
(
$template
->
error
);
}
$cache
->
{
$lang
}
=
\%
vars
;
return
$vars
{
$name
};
}
sub
disable_utf8
{
if
(
Bugzilla
->
params
->
{
'utf8'
})
{
binmode
STDOUT
,
':bytes'
;
# Turn off UTF8 encoding.
...
...
@@ -902,6 +922,14 @@ A string.
=back
=item C<template_var>
This is a method of getting the value of a variable from a template in
Perl code. The available variables are in the C<global/field-descs.none.tmpl>
template. Just pass in the name of the variable that you want the value of.
=back
=head2 Formatting Time
...
...
extensions/Voting/template/en/default/hook/global/field-descs-end.none.tmpl
View file @
217beee4
...
...
@@ -18,5 +18,6 @@
# Max Kanat-Alexander <mkanat@bugzilla.org>
#%]
[% field_descs.votes = "Votes" %]
[% IF in_template_var %]
[% vars.field_descs.votes = "Votes" %]
[% END %]
template/en/default/global/field-descs.none.tmpl
View file @
217beee4
...
...
@@ -23,7 +23,79 @@
[% PROCESS global/variables.none.tmpl %]
[% field_descs = { "[Bug creation]" => "[$terms.Bug creation]",
[% SET search_descs = {
"noop" => "---",
"equals" => "is equal to",
"notequals" => "is not equal to",
"anyexact" => "is equal to any of the strings",
"substring" => "contains the string",
"casesubstring" => "contains the string (exact case)",
"notsubstring" => "does not contain the string",
"anywordssubstr" => "contains any of the strings",
"allwordssubstr" => "contains all of the strings",
"nowordssubstr" => "contains none of the strings",
"regexp" => "matches regular expression",
"notregexp" => "does not match regular expression",
"lessthan" => "is less than",
"lessthaneq" => "is less than or equal to",
"greaterthan" => "is greater than",
"greaterthaneq" => "is greater than or equal to",
"anywords" => "contains any of the words",
"allwords" => "contains all of the words",
"nowords" => "contains none of the words",
"changedbefore" => "changed before",
"changedafter" => "changed after",
"changedfrom" => "changed from",
"changedto" => "changed to",
"changedby" => "changed by",
"matches" => "matches",
} %]
[% field_types = { ${constants.FIELD_TYPE_UNKNOWN} => "Unknown Type",
${constants.FIELD_TYPE_FREETEXT} => "Free Text",
${constants.FIELD_TYPE_SINGLE_SELECT} => "Drop Down",
${constants.FIELD_TYPE_MULTI_SELECT} => "Multiple-Selection Box",
${constants.FIELD_TYPE_TEXTAREA} => "Large Text Box",
${constants.FIELD_TYPE_DATETIME} => "Date/Time",
${constants.FIELD_TYPE_BUG_ID} => "$terms.Bug ID",
} %]
[%# You can use this hash to localize (translate) the values displayed
# for drop-down and multiple-select fields. Lines starting with "#"
# are comments.
#%]
[% value_descs = {
"bug_status" => {
# "UNCONFIRMED" => "UNCO",
# "NEW" => "NEWISH",
},
"resolution" => {
"" => "---",
# "FIXED" => "NO LONGER AN ISSUE",
# "MOVED" => "BYE-BYE",
},
} %]
[%# We use "FILTER none" here because only the caller can know how to
# filter the result appropriately.
#%]
[% MACRO display_value(field_name, value_name) BLOCK %][% FILTER trim %]
[% IF value_descs.${field_name}.${value_name}.defined %]
[% value_descs.${field_name}.${value_name} FILTER none %]
[% ELSE %]
[% value_name FILTER none %]
[% END %]
[% END %][% END %]
[% IF in_template_var %]
[% vars.terms = terms %]
[%# field_descs is loaded as a global template variable and cached
# across all templates--see VARIABLES in Bugzilla/Template.pm.
#%]
[% vars.field_descs = {
"[Bug creation]" => "[$terms.Bug creation]",
"actual_time" => "Actual Hours",
"alias" => "Alias",
"assigned_to" => "Assignee",
...
...
@@ -84,82 +156,19 @@
"status_whiteboard" => "Whiteboard",
"target_milestone" => "Target Milestone",
"version" => "Version",
"work_time" => "Hours Worked"} %]
"work_time" => "Hours Worked",
} %]
[%# Also include any custom fields or fields which don't have a
[%# Also include any custom fields or fields which don't have a
Description here, by copying their Description from the
database. If you want to override this for your language
or your installation, just use a hook. %]
[% UNLESS Param('shutdownhtml') %]
[% UNLESS Param('shutdownhtml') %]
[% FOREACH bz_field = bug_fields.values %]
[% SET
field_descs.${bz_field.name} = bz_field.description
IF !
field_descs.${bz_field.name}.defined %]
[% SET vars.
field_descs.${bz_field.name} = bz_field.description
IF !vars.
field_descs.${bz_field.name}.defined %]
[% END %]
[% END %]
[% SET search_descs = {
"noop" => "---",
"equals" => "is equal to",
"notequals" => "is not equal to",
"anyexact" => "is equal to any of the strings",
"substring" => "contains the string",
"casesubstring" => "contains the string (exact case)",
"notsubstring" => "does not contain the string",
"anywordssubstr" => "contains any of the strings",
"allwordssubstr" => "contains all of the strings",
"nowordssubstr" => "contains none of the strings",
"regexp" => "matches regular expression",
"notregexp" => "does not match regular expression",
"lessthan" => "is less than",
"lessthaneq" => "is less than or equal to",
"greaterthan" => "is greater than",
"greaterthaneq" => "is greater than or equal to",
"anywords" => "contains any of the words",
"allwords" => "contains all of the words",
"nowords" => "contains none of the words",
"changedbefore" => "changed before",
"changedafter" => "changed after",
"changedfrom" => "changed from",
"changedto" => "changed to",
"changedby" => "changed by",
"matches" => "matches",
} %]
[% field_types = { ${constants.FIELD_TYPE_UNKNOWN} => "Unknown Type",
${constants.FIELD_TYPE_FREETEXT} => "Free Text",
${constants.FIELD_TYPE_SINGLE_SELECT} => "Drop Down",
${constants.FIELD_TYPE_MULTI_SELECT} => "Multiple-Selection Box",
${constants.FIELD_TYPE_TEXTAREA} => "Large Text Box",
${constants.FIELD_TYPE_DATETIME} => "Date/Time",
${constants.FIELD_TYPE_BUG_ID} => "$terms.Bug ID",
} %]
[%# You can use this hash to localize (translate) the values displayed
# for drop-down and multiple-select fields. Lines starting with "#"
# are comments.
#%]
[% value_descs = {
"bug_status" => {
# "UNCONFIRMED" => "UNCO",
# "NEW" => "NEWISH",
},
"resolution" => {
"" => "---",
# "FIXED" => "NO LONGER AN ISSUE",
# "MOVED" => "BYE-BYE",
},
} %]
[%# We use "FILTER none" here because only the caller can know how to
# filter the result appropriately.
#%]
[% MACRO display_value(field_name, value_name) BLOCK %][% FILTER trim %]
[% IF value_descs.${field_name}.${value_name}.defined %]
[% value_descs.${field_name}.${value_name} FILTER none %]
[% ELSE %]
[% value_name FILTER none %]
[% END %]
[% END %]
[% END %]
[% END %]
[% Hook.process("end") %]
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