diff options
author | Byron Jones <bjones@mozilla.com> | 2012-08-08 22:00:48 +0800 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2012-08-08 22:00:48 +0800 |
commit | 17a866fde027a1236cfadc7829d0176a60dc4b51 (patch) | |
tree | 29cebba6bde82bf5e6d414668c5808dcf4e40db4 | |
parent | Bug 781059: -moz-border-radius is obsolete and must be replaced by the standa... (diff) | |
download | bugzilla-17a866fde027a1236cfadc7829d0176a60dc4b51.tar.gz bugzilla-17a866fde027a1236cfadc7829d0176a60dc4b51.tar.bz2 bugzilla-17a866fde027a1236cfadc7829d0176a60dc4b51.zip |
Bug 778631: use a persistent Template::Provider to avoid recompiling templates between page loads on mod_perl
r=dkl, a=LpSolit
-rw-r--r-- | Bugzilla/Template.pm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 87c8696b7..a38d07e7f 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -40,6 +40,10 @@ use constant FORMAT_3_SIZE => [19,28,28]; use constant FORMAT_DOUBLE => '%19s %-55s'; use constant FORMAT_2_SIZE => [19,55]; +# Use a per-process provider to cache compiled templates in memory across +# requests. +our %shared_providers; + # Pseudo-constant. sub SAFE_URL_REGEXP { my $safe_protocols = join('|', SAFE_PROTOCOLS); @@ -603,6 +607,10 @@ sub create { COMPILE_DIR => bz_locations()->{'template_cache'}, + # Don't check for a template update until 1 hour has passed since the + # last check. + STAT_TTL => 60 * 60, + # Initialize templates (f.e. by loading plugins like Hook). PRE_PROCESS => ["global/variables.none.tmpl"], @@ -973,6 +981,9 @@ sub create { 'default_authorizer' => new Bugzilla::Auth(), }, }; + my $provider_key = join(':', @{ $config->{INCLUDE_PATH} }); + $shared_providers{$provider_key} ||= Template::Provider->new($config); + $config->{LOAD_TEMPLATES} = [ $shared_providers{$provider_key} ]; local $Template::Config::CONTEXT = 'Bugzilla::Template::Context'; @@ -1037,6 +1048,9 @@ sub precompile_templates { # effect of writing the compiled version to disk. $template->context->template($file); } + + # Clear out the cached Provider object + undef %shared_providers; } # Under mod_perl, we look for templates using the absolute path of the |