LP#1485374: Adjust TZ scope in mod_perl
authorMike Rylander <mrylander@gmail.com>
Tue, 23 Feb 2016 17:32:57 +0000 (12:32 -0500)
committerMike Rylander <mrylander@gmail.com>
Thu, 18 Aug 2016 14:45:51 +0000 (10:45 -0400)
Use of a 'local' variable causes the TZ to be dropped prematurely. So,
instead, we set $ENV{TZ} globally and reset it when the mod_perl handler
object is destroyed.

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

index 0bf86c7..c5b2840 100644 (file)
@@ -57,6 +57,11 @@ sub new {
     return $self;
 }
 
+sub DESTROY {
+    my $self = shift;
+    $ENV{TZ} = $self->ctx->{original_tz}
+        if ($self->ctx && exists $self->ctx->{original_tz});
+}
 
 # current Apache2::RequestRec;
 sub apache {
@@ -269,7 +274,8 @@ sub load_common {
     $ctx->{unparsed_uri} = $self->apache->unparsed_uri;
     $ctx->{opac_root} = $ctx->{base_path} . "/opac"; # absolute base url
 
-    local $ENV{TZ} = $ctx->{client_tz};
+    $ctx->{original_tz} = $ENV{TZ};
+    $ENV{TZ} = $ctx->{client_tz};
 
     my $xul_wrapper = 
         ($self->apache->headers_in->get('OILS-Wrapper') || '') =~ /true/;