]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 797883: Adds a Bugzilla->process_cache
authorByron Jones <bjones@mozilla.com>
Thu, 4 Oct 2012 16:49:53 +0000 (00:49 +0800)
committerByron Jones <bjones@mozilla.com>
Thu, 4 Oct 2012 16:49:53 +0000 (00:49 +0800)
r=LpSolit, a=LpSolit

Bugzilla.pm
Bugzilla/Template.pm

index f956f5a0ea6a63e5820d66fa1f6ebae12ddd9c4f..6c86fb0fc06061251421bf37406570d6d34d15c1 100644 (file)
@@ -271,8 +271,7 @@ sub input_params {
 
 our $_localconfig;
 sub localconfig {
-    $_localconfig ||= read_localconfig();
-    return $_localconfig;
+    return $_[0]->process_cache->{localconfig} ||= read_localconfig();
 }
 
 sub params {
@@ -643,6 +642,15 @@ sub request_cache {
     return $_request_cache;
 }
 
+# This is a per-process cache.  Under mod_cgi it's identical to the
+# request_cache.  When using mod_perl, items in this cache live until the
+# worker process is terminated.
+our $_process_cache = {};
+
+sub process_cache {
+    return $_process_cache;
+}
+
 # Private methods
 
 # Per-process cleanup. Note that this is a plain subroutine, not a method,
index 6685a74318233c7ac9f3181bda5b0c54d8230522..f6796dfc779f30ba7b6d3e772f024dab90c3d72c 100644 (file)
@@ -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