MFHD compressed holdings short-circuit logic
authorDan Wells <dbw2@calvin.edu>
Tue, 21 Jun 2011 15:44:10 +0000 (11:44 -0400)
committerDan Scott <dan@coffeecode.net>
Wed, 22 Jun 2011 03:34:41 +0000 (23:34 -0400)
If you attempt to get compressed (or uncompressed) holdings from
a MFHD record with only a caption, the code should short-circuit
and return an empty list.

Signed-off-by: Dan Wells <dbw2@calvin.edu>
Signed-off-by: Dan Scott <dan@coffeecode.net>
Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm

index 48f00cb..5b728c0 100644 (file)
@@ -357,6 +357,8 @@ sub get_compressed_holdings {
         @decomp_holdings = $self->get_decompressed_holdings($caption, {'dedupe' => 1});
     }
 
+    return () if !@decomp_holdings;
+
     my $runner = $decomp_holdings[0]->clone->increment;   
     my $curr_holding = shift(@decomp_holdings);
     $curr_holding = $curr_holding->clone;
@@ -414,6 +416,9 @@ sub get_decompressed_holdings {
     my $link_id = $caption->link_id;
     $htag =~ s/^85/86/;
     my @holdings = $self->holdings($htag, $link_id);
+
+    return () if !@holdings;
+
     my @decomp_holdings;
 
     foreach my $holding (@holdings) {