LP#1449709: Always get a real hostname for the cache key collab/gmcharlt/lp1449709-TT-caching-by-egweb
authorMike Rylander <mrylander@gmail.com>
Fri, 22 May 2015 17:11:18 +0000 (13:11 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 22 May 2015 17:11:18 +0000 (13:11 -0400)
EGCatLoader overwrites $ctx->{hostname} when serving the staff client
version of TT-generated content.  This is bad for us because we use
that as part of the TT Processor cache key.  Instead, we'll just
always ask Apache, via $r.

Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm

index 8b3fcbf..3dbbacc 100644 (file)
@@ -62,7 +62,7 @@ sub handler_guts {
     my $text_handler = set_text_handler($ctx, $r);
 
     my $processor_key = $as_xml ? 'xml:' : 'text:';                 # separate by XML strictness
-    $processor_key .= $ctx->{hostname}.':';                         # ... and vhost
+    $processor_key .= $r->hostname.':';                         # ... and vhost
     $processor_key .= $r->dir_config('OILSWebContextLoader').':';   # ... and context loader
     $processor_key .= $ctx->{locale};                               # ... and locale
     # NOTE: context loader and vhost together imply template path and debug template values
@@ -273,8 +273,8 @@ sub find_template {
     my $ext = $r->dir_config('OILSWebDefaultTemplateExtension');
     my $at_index = $r->dir_config('OILSWebStopAtIndex');
 
-    $vhost_path_cache{$ctx->{hostname}} ||= {};
-    my $path_cache = $vhost_path_cache{$ctx->{hostname}};
+    $vhost_path_cache{$r->hostname} ||= {};
+    my $path_cache = $vhost_path_cache{$r->hostname};
 
     my @parts = split('/', $path);
     my $localpath = $path;