Avoid CStoreEditor failures on missing log-protect
authorBill Erickson <berick@esilibrary.com>
Wed, 16 Jan 2013 14:39:56 +0000 (09:39 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 16 Jan 2013 15:06:42 +0000 (10:06 -0500)
When the log_protect configuration chunk is not present in
opensrf_core.xml, gracefully move on without it.  This prevents errors
like:

Can't call method \"shared\" on an undefined value at
/usr/local/share/perl/5.10.1/OpenILS/Utils/CStoreEditor.pm line 646.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/perlmods/lib/OpenILS/Utils/CStoreEditor.pm

index 23559e0..0a70648 100644 (file)
@@ -642,14 +642,18 @@ sub log_activity {
        my $str = "$type.$action";
 
     if ($arg) {
-
-        my $redact = $OpenSRF::Application::shared_conf->shared->log_protect;
-        if (ref($redact) eq 'ARRAY' and grep { $method =~ /^$_/ } @{$redact}) {
-
-            # when API calls are marked as log-protect, avoid 
-            # dumping the param object to the activity log.
-            $str .= " **DETAILS REDACTED**";
-
+        
+        my $redact;
+
+        if ($OpenSRF::Application::shared_conf and
+            $OpenSRF::Application::shared_conf->shared and
+            $redact = $OpenSRF::Application::shared_conf->shared->log_protect and
+            ref($redact) eq 'ARRAY' and
+            grep { $method =~ /^$_/ } @{$redact}) {
+
+                # when API calls are marked as log-protect, avoid
+                # dumping the param object to the activity log.
+                $str .= " **DETAILS REDACTED**";
         } else {
 
             $str .= _prop_string($arg);