From: Dan Wells Date: Tue, 27 Sep 2011 16:22:38 +0000 (-0400) Subject: MFHD compression fails with pattern-less captions X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=e9cd94c0831322cae41b16b6b0a08565fe3ea7ff;p=evergreen%2Ftadl.git MFHD compression fails with pattern-less captions The current code assumes that if you try to compress a range of MFHD holdings, you actually have the necessary pattern information. This commit introduces a very basic check to avoid the most common failure case. Signed-off-by: Dan Wells Signed-off-by: Mike Rylander --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm index 6964c56d1b..309f9fe02b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm @@ -358,6 +358,12 @@ sub get_compressed_holdings { my $opts = shift; my $skip_sort = $opts->{'skip_sort'}; + # basic check for necessary pattern information + if (!scalar keys %{$caption->pattern}) { + carp "Cannot compress without pattern data, returning original holdings"; + return $self->holdings_by_caption($caption); + } + # make sure none are compressed (except for open-ended) my @decomp_holdings; if ($skip_sort) { diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm index 94458343eb..d949b4e3f7 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm @@ -128,6 +128,12 @@ sub decode_pattern { # XXX WRITE ME (?) } +sub pattern { + my $self = shift; + + return $self->{_mfhdc_PATTERN}; +} + sub compressible { my $self = shift;