From 96ef286867ca2e8b81e5c4f0e3e1bc180e84539c Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Tue, 2 May 2017 09:39:05 -0400 Subject: Revert "Bug 1352264 - Preload all templates" This reverts commit c82963a57cf97932870e11de8cf2a6205132b954. --- Bugzilla/Template.pm | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'Bugzilla/Template.pm') diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 5a14a8e85..b08cffbde 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -12,7 +12,6 @@ use 5.10.1; use strict; use warnings; -use Bugzilla::Template::PreloadProvider; use Bugzilla::Bug; use Bugzilla::Constants; use Bugzilla::Hook; @@ -48,8 +47,6 @@ use constant FORMAT_3_SIZE => [19,28,28]; use constant FORMAT_DOUBLE => '%19s %-55s'; use constant FORMAT_2_SIZE => [19,55]; -my %SHARED_PROVIDERS; - # Pseudo-constant. sub SAFE_URL_REGEXP { my $safe_protocols = join('|', SAFE_PROTOCOLS); @@ -976,12 +973,10 @@ sub create { PLUGIN_BASE => 'Bugzilla::Template::Plugin', + CONSTANTS => _load_constants(), + # Default variables for all templates VARIABLES => { - # Some of these are not really constants, and doing this messes up preloading. - # they are now fake constants. - constants => _load_constants(), - # Function for retrieving global parameters. 'Param' => sub { return Bugzilla->params->{$_[0]}; }, @@ -1120,18 +1115,12 @@ sub create { 'is_mobile_browser' => sub { return Bugzilla->cgi->user_agent =~ /Mobi/ }, }, }; - - # under mod_perl, use a provider (template loader) that preloads all templates into memory - my $provider_class - = $ENV{MOD_PERL} - ? 'Bugzilla::Template::PreloadProvider' - : 'Template::Provider'; - # Use a per-process provider to cache compiled templates in memory across # requests. my $provider_key = join(':', @{ $config->{INCLUDE_PATH} }); - $SHARED_PROVIDERS{$provider_key} ||= $provider_class->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} ]; # BMO - use metrics subclass local $Template::Config::CONTEXT = Bugzilla->metrics_enabled() @@ -1220,7 +1209,7 @@ sub precompile_templates { delete Bugzilla->request_cache->{template}; # Clear out the cached Provider object - %SHARED_PROVIDERS = (); + Bugzilla->process_cache->{shared_providers} = undef; print install_string('done') . "\n" if $output; } -- cgit v1.2.3-24-g4f1b