safety checks for return values of new helper method collab/dbwells/serial_unit_titles
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 18 Sep 2013 17:50:51 +0000 (13:50 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 18 Sep 2013 17:50:51 +0000 (13:50 -0400)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Holding.pm

index a3836ef..a06db2b 100644 (file)
@@ -142,7 +142,7 @@ sub field_values {
 sub unit_titles {
     my ($self, $key) = @_;
 
-    if (exists $self->fields->{$key}) {
+    if (defined $self->fields->{$key}{UNIT_TITLES}) {
         # this dereferences and makes a new reference to make sure
         # the return value is a copy (not pointing to the object data)
         my @titles = @{$self->fields->{$key}{UNIT_TITLES}};
@@ -474,7 +474,7 @@ sub format {
         ($holding_start{$key}, $holding_end{$key}) =
           @{$self->field_values($key)};
         ($holding_start{$key . '_title'}, $holding_end{$key . '_title'}) =
-          @{$self->unit_titles($key)};
+          @{$self->unit_titles($key)} if $self->unit_titles($key);
     }
 
     if ($self->is_compressed) {