From f7d1f7b803a9e89be4407d102a48eddd1708e103 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Fri, 5 Oct 2012 00:49:53 +0800 Subject: Bug 797883: Adds a Bugzilla->process_cache r=LpSolit, a=LpSolit --- Bugzilla/Template.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'Bugzilla/Template.pm') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 6685a7431..f6796dfc7 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -41,10 +41,6 @@ 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); @@ -982,9 +978,12 @@ sub create { 'default_authorizer' => new Bugzilla::Auth(), }, }; + # Use a per-process provider to cache compiled templates in memory across + # requests. my $provider_key = join(':', @{ $config->{INCLUDE_PATH} }); - $shared_providers{$provider_key} ||= Template::Provider->new($config); - $config->{LOAD_TEMPLATES} = [ $shared_providers{$provider_key} ]; + my $shared_providers = Bugzilla->process_cache->{shared_providers} ||= {}; + $shared_providers->{$provider_key} ||= Template::Provider->new($config); + $config->{LOAD_TEMPLATES} = [ $shared_providers->{$provider_key} ]; local $Template::Config::CONTEXT = 'Bugzilla::Template::Context'; @@ -1051,7 +1050,7 @@ sub precompile_templates { } # Clear out the cached Provider object - undef %shared_providers; + Bugzilla->process_cache->{shared_providers} = undef; } # Under mod_perl, we look for templates using the absolute path of the -- cgit v1.2.3-24-g4f1b