summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Template.pm
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2012-08-07 11:31:06 +0200
committerByron Jones <bjones@mozilla.com>2012-08-07 11:31:06 +0200
commit6dddd9e477ecccc37c8d57f16238ea78b5cb638e (patch)
tree20d1c88d9bb3bfccf37da33181da039a4588d999 /Bugzilla/Template.pm
parent390de95d9f3f08e943298942ab69780758e76944 (diff)
downloadbugzilla-6dddd9e477ecccc37c8d57f16238ea78b5cb638e.tar.gz
bugzilla-6dddd9e477ecccc37c8d57f16238ea78b5cb638e.tar.xz
Bug 778631: use a persistent Template::Provider to avoid recompiling templates between page loads on mod_perl
r=dkl, a=LpSolit
Diffstat (limited to 'Bugzilla/Template.pm')
-rw-r--r--Bugzilla/Template.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm
index 87c8696b7..4bc2c32e6 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_provider;
+
# 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,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';