LP#1752753: Guard against invalid timezone user/jeffdavis/lp1752753-invalid-timezone
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Fri, 2 Mar 2018 00:55:46 +0000 (16:55 -0800)
committerJeff Davis <jdavis@sitka.bclibraries.ca>
Fri, 2 Mar 2018 00:55:46 +0000 (16:55 -0800)
If the lib.timezone org setting is not a valid timezone, attempting to
use it can result in an internal server error in the OPAC.  Let's handle
the error with try/catch instead.

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Util.pm

index 7ecddc8..8e24b07 100644 (file)
@@ -273,7 +273,13 @@ sub init_ro_object_cache {
         if ($context_org) {
             $context_org = $context_org->id if ref($context_org);
             my $tz = $locale_subs->{get_org_setting}->($context_org,'lib.timezone');
-            $date->set_time_zone($tz) if ($tz);
+            if ($tz) {
+                try {
+                    $date->set_time_zone($tz);
+                } catch Error with {
+                    $logger->warn("Invalid timezone: $z");
+                };
+            }
         }
         return sprintf(
             "%0.2d:%0.2d:%0.2d %0.2d-%0.2d-%0.4d",