Commit 39888980 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 634812: Having a very large number of custom fields can make displaying show_bug.cgi slow

r=glob a=LpSolit
parent bc82259f
...@@ -936,6 +936,11 @@ sub create { ...@@ -936,6 +936,11 @@ sub create {
# it only once per-language no matter how many times # it only once per-language no matter how many times
# $template->process() is called. # $template->process() is called.
'field_descs' => sub { return template_var('field_descs') }, 'field_descs' => sub { return template_var('field_descs') },
# Calling bug/field-help.none.tmpl once per label is very
# expensive, so we generate it once per-language.
'help_html' => sub { return template_var('help_html') },
# This way we don't have to load field-descs.none.tmpl in # This way we don't have to load field-descs.none.tmpl in
# many templates. # many templates.
'display_value' => \&Bugzilla::Util::display_value, 'display_value' => \&Bugzilla::Util::display_value,
......
...@@ -19,11 +19,13 @@ ...@@ -19,11 +19,13 @@
# Max Kanat-Alexander <mkanat@bugzilla.org> # Max Kanat-Alexander <mkanat@bugzilla.org>
#%] #%]
[%# This file describes both bug fields and search fields. %] [%# This file describes both bug fields and search fields.
# As calling this template once per label is very expensive,
# it is called only by Template.pm. %]
[% PROCESS "global/field-descs.none.tmpl" %] [% RETURN UNLESS in_template_var %]
[% help_html = { [% vars.help_html = {
# Note that all these keys here are in alphabetical order, though # Note that all these keys here are in alphabetical order, though
# search-specific fields are at the bottom. # search-specific fields are at the bottom.
...@@ -100,7 +102,7 @@ op_sys => ...@@ -100,7 +102,7 @@ op_sys =>
percentage_complete => percentage_complete =>
"How close to 100% done this $terms.bug is, by comparing its "How close to 100% done this $terms.bug is, by comparing its
$field_descs.work_time to its ${field_descs.estimated_time}.", $vars.field_descs.work_time to its ${vars.field_descs.estimated_time}.",
priority => priority =>
"Engineers prioritize their $terms.bugs using this field.", "Engineers prioritize their $terms.bugs using this field.",
...@@ -116,8 +118,8 @@ qa_contact => ...@@ -116,8 +118,8 @@ qa_contact =>
remaining_time => remaining_time =>
"The number of hours of work left on this $terms.bug, calculated by "The number of hours of work left on this $terms.bug, calculated by
subtracting the $field_descs.work_time from the subtracting the $vars.field_descs.work_time from the
${field_descs.estimated_time}.", ${vars.field_descs.estimated_time}.",
rep_platform => rep_platform =>
"The hardware platform the $terms.bug was observed on.", "The hardware platform the $terms.bug was observed on.",
...@@ -137,8 +139,8 @@ see_also => ...@@ -137,8 +139,8 @@ see_also =>
<p>You should normally use this field to refer to $terms.bugs in <p>You should normally use this field to refer to $terms.bugs in
<em>other</em> installations. For $terms.bugs in this <em>other</em> installations. For $terms.bugs in this
installation, it is better to use the $field_descs.dependson and installation, it is better to use the $vars.field_descs.dependson and
$field_descs.blocked fields.</p>", $vars.field_descs.blocked fields.</p>",
short_desc => short_desc =>
"The $terms.bug summary is a short sentence which succinctly" "The $terms.bug summary is a short sentence which succinctly"
...@@ -149,7 +151,7 @@ status_whiteboard => ...@@ -149,7 +151,7 @@ status_whiteboard =>
_ " adding tags and status information.", _ " adding tags and status information.",
target_milestone => target_milestone =>
"The $field_descs.target_milestone field is used to define when the" "The $vars.field_descs.target_milestone field is used to define when the"
_ " engineer the $terms.bug is assigned to expects to fix it.", _ " engineer the $terms.bug is assigned to expects to fix it.",
version => version =>
...@@ -185,8 +187,8 @@ chfieldvalue => ...@@ -185,8 +187,8 @@ chfieldvalue =>
content => content =>
"This is a field available in searches that does a Google-like "This is a field available in searches that does a Google-like
'full-text' search on the $field_descs.short_desc and 'full-text' search on the $vars.field_descs.short_desc and
$field_descs.longdesc fields.", $vars.field_descs.longdesc fields.",
# Duplicated to email2 below, also. # Duplicated to email2 below, also.
email1 => email1 =>
...@@ -195,10 +197,10 @@ email1 => ...@@ -195,10 +197,10 @@ email1 =>
} %] } %]
[% help_html.email2 = help_html.email1 %] [% vars.help_html.email2 = vars.help_html.email1 %]
[% help_html.chfieldto = help_html.chfieldfrom %] [% vars.help_html.chfieldto = vars.help_html.chfieldfrom %]
[% help_html.deadlinefrom = help_html.deadline %] [% vars.help_html.deadlinefrom = vars.help_html.deadline %]
[% help_html.deadlineto = help_html.deadline %] [% vars.help_html.deadlineto = vars.help_html.deadline %]
[% help_all_note = BLOCK %] [% help_all_note = BLOCK %]
<strong>Note:</strong> When searching, selecting the option "All" <strong>Note:</strong> When searching, selecting the option "All"
...@@ -206,34 +208,34 @@ email1 => ...@@ -206,34 +208,34 @@ email1 =>
the word "All". the word "All".
[% END %] [% END %]
[% FOREACH all_field = ['op_sys', 'rep_platform'] %] [% FOREACH all_field = ['op_sys', 'rep_platform'] %]
[% help_html.$all_field = help_html.$all_field _ ' ' _ help_all_note %] [% vars.help_html.$all_field = vars.help_html.$all_field _ ' ' _ help_all_note %]
[% END %] [% END %]
[% IF Param('useclassification') %] [% IF Param('useclassification') %]
[% help_html.product = help_html.product [% vars.help_html.product = vars.help_html.product
_ " Select a Classification to narrow down this list." %] _ " Select a Classification to narrow down this list." %]
[% END %] [% END %]
[% FOREACH help_field = bug_fields.keys %] [% FOREACH help_field = bug_fields.keys %]
[%# Add help for custom fields. %] [%# Add help for custom fields. %]
[% IF !help_html.${help_field}.defined %] [% IF !vars.help_html.${help_field}.defined %]
[% SET field_type = bug_fields.${help_field}.type %] [% SET field_type = bug_fields.${help_field}.type %]
[% field_type_desc = BLOCK -%] [% field_type_desc = BLOCK -%]
[% field_types.$field_type FILTER html %] [% field_types.$field_type FILTER html %]
[%- END %] [%- END %]
[% help_html.${help_field} = [% vars.help_html.${help_field} =
"A custom $field_type_desc field in this installation" "A custom $field_type_desc field in this installation"
_ " of ${terms.Bugzilla}." %] _ " of ${terms.Bugzilla}." %]
[% END %] [% END %]
[%# Add help for the search types, for query.cgi. %] [%# Add help for the search types, for query.cgi. %]
[% type_desc = BLOCK %] [% type_desc = BLOCK %]
The type of [% field_descs.${help_field} FILTER html %] search you The type of [% vars.field_descs.${help_field} FILTER html %] search you
would like. would like.
[% END %] [% END %]
[% SET type_name = help_field _ '_type' %] [% SET type_name = help_field _ '_type' %]
[% help_html.$type_name = type_desc %] [% vars.help_html.$type_name = type_desc %]
[% END %] [% END %]
[% Hook.process("end") %] [% Hook.process("end") %]
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
# tag_name: the tag to use to surround the label # tag_name: the tag to use to surround the label
#%] #%]
[% PROCESS "bug/field-help.none.tmpl" %]
[% DEFAULT tag_name = "th" %] [% DEFAULT tag_name = "th" %]
<[% tag_name FILTER html %] class="field_label [% ' bz_hidden_field' IF hidden %] <[% tag_name FILTER html %] class="field_label [% ' bz_hidden_field' IF hidden %]
[%- ' required' IF field.is_mandatory && NOT bug.id %]" [%- ' required' IF field.is_mandatory && NOT bug.id %]"
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
"component" => "Component", "component" => "Component",
"content" => "Content", "content" => "Content",
"creation_ts" => "Creation date", "creation_ts" => "Creation date",
"days_elapsed" => "Days since bug changed", "days_elapsed" => "Days since $terms.bug changed",
"deadline" => "Deadline", "deadline" => "Deadline",
"delta_ts" => "Changed", "delta_ts" => "Changed",
"dependson" => "Depends on", "dependson" => "Depends on",
...@@ -149,6 +149,8 @@ ...@@ -149,6 +149,8 @@
IF !vars.field_descs.${bz_field.name}.defined %] IF !vars.field_descs.${bz_field.name}.defined %]
[% END %] [% END %]
[% END %] [% END %]
[% PROCESS "bug/field-help.none.tmpl" %]
[% END %] [% END %]
[% Hook.process("end") %] [% Hook.process("end") %]
...@@ -188,8 +188,6 @@ ...@@ -188,8 +188,6 @@
<h2>Other Fields</h2> <h2>Other Fields</h2>
[% PROCESS "bug/field-help.none.tmpl" %]
[% SET field_help_map = {} %] [% SET field_help_map = {} %]
[% FOREACH field = bug_fields.keys %] [% FOREACH field = bug_fields.keys %]
[% SET field_desc = field_descs.$field %] [% SET field_desc = field_descs.$field %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment