summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-08-07 11:35:13 +0200
committerByron Jones <bjones@mozilla.com>2012-08-07 11:35:13 +0200
commitb037f9bf0993f519375f6dfa0c514529d48b7f23 (patch)
treef7bc234352cbbf42711af3e44eb852da544c3eea /Bugzilla
parentf94befed1c326a403550182b3fb56e6731e5d276 (diff)
downloadbugzilla-b037f9bf0993f519375f6dfa0c514529d48b7f23.tar.gz
bugzilla-b037f9bf0993f519375f6dfa0c514529d48b7f23.tar.xz
Bug 778631: use a persistent Template::Provider to avoid recompiling templates between page loads
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/Template.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 245d881d3..fb6c5ad1d 100644
--- a/Bugzilla/Template.pm
+++ b/Bugzilla/Template.pm
@@ -66,6 +66,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_provider;
+
# Pseudo-constant.
sub SAFE_URL_REGEXP {
my $safe_protocols = join('|', SAFE_PROTOCOLS);
@@ -617,6 +621,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/initialize.none.tmpl"],
@@ -997,6 +1005,8 @@ sub create {
'default_authorizer' => new Bugzilla::Auth(),
},
};
+ $shared_provider ||= Template::Provider->new($config);
+ $config->{LOAD_TEMPLATES} = [ $shared_provider ];
local $Template::Config::CONTEXT = 'Bugzilla::Template::Context';