improve caching of TT processors
authorGalen Charlton <gmc@esilibrary.com>
Tue, 5 May 2015 15:32:13 +0000 (15:32 +0000)
committerGalen Charlton <gmc@esilibrary.com>
Tue, 5 May 2015 15:35:21 +0000 (15:35 +0000)
- remove a missing variable from cache key that was
  preventing compilation
- explicitly pass the Apache2::RequestRec object to
  $tt->process(); this ensures that output is going
  back on the correct socket and avoids segfaulting
  Apache workers.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm

index 5ead7c5..db0645d 100644 (file)
@@ -64,7 +64,7 @@ sub handler_guts {
     my $processor_key = $as_xml ? 'xml:' : 'text:';                 # separate by XML strictness
     $processor_key .= $ctx->{hostname}.':';                         # ... and vhost
     $processor_key .= $r->dir_config('OILSWebContextLoader').':';   # ... and context loader
-    $processor_key .= $uri_section.':'.$ctx->{locale};              # ... and locale
+    $processor_key .= $ctx->{locale};                               # ... and locale
     # NOTE: context loader and vhost together imply template path and debug template values
     # TODO: maybe add STAT_TTL and cache dir from LP#1449709?
 
@@ -96,7 +96,7 @@ sub handler_guts {
     $vhost_processor_cache{$processor_key} = $tt;
     $ctx->{encode_utf8} = sub {return encode_utf8(shift())};
 
-    unless($tt->process($template, {ctx => $ctx, ENV => \%ENV, l => $text_handler})) {
+    unless($tt->process($template, {ctx => $ctx, ENV => \%ENV, l => $text_handler}, $r)) {
         $r->log->warn('egweb: template error: ' . $tt->error);
         return Apache2::Const::HTTP_INTERNAL_SERVER_ERROR;
     }