]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 498318: Speed up field-descs.none.tmpl
authormkanat%bugzilla.org <>
Sun, 21 Jun 2009 19:37:18 +0000 (19:37 +0000)
committermkanat%bugzilla.org <>
Sun, 21 Jun 2009 19:37:18 +0000 (19:37 +0000)
Patch by Max Kanat-Alexander <mkanat@bugzilla.org> r=bbaetz, a=mkanat

Bugzilla/Template.pm
template/en/default/global/field-descs.none.tmpl

index 8c34bb493e87a24447d3ab81d161fd96251c9a8f..c8ce711b83d4e0c739f6a56d42cad835f451c5c2 100644 (file)
@@ -769,6 +769,14 @@ sub create {
             # Allow templates to generate a token themselves.
             'issue_hash_token' => \&Bugzilla::Token::issue_hash_token,
 
+            # A way for all templates to get at Field data, cached.
+            'bug_fields' => sub {
+                my $cache = Bugzilla->request_cache;
+                $cache->{template_bug_fields} ||= 
+                    { map { $_->name => $_ } Bugzilla->get_fields() };
+                return $cache->{template_bug_fields};
+            },
+
             # These don't work as normal constants.
             DB_MODULE        => \&Bugzilla::Constants::DB_MODULE,
             REQUIRED_MODULES => 
index 6160784eed06c18ee9162ff7d4aca8ab4c73b47b..2c70b11c63073a4db1eef0058c0f1cd3b0295824 100644 (file)
     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. %]
-[%# Also create the bug_fields hash. %]
 [% UNLESS Param('shutdownhtml') %]
-  [% USE Bugzilla %]
-  [% SET bug_fields = {} %]
-  [% FOREACH bz_field = Bugzilla.get_fields() %]
+  [% FOREACH bz_field = bug_fields.values %]
     [% SET field_descs.${bz_field.name} = bz_field.description
        IF !field_descs.${bz_field.name}.defined %]
-    [% SET bug_fields.${bz_field.name} = bz_field %]
   [% END %]
 [% END %]