From 6970e27424e43fa35c2e876025bfe89091b553f2 Mon Sep 17 00:00:00 2001 From: Dan Wells Date: Tue, 27 Sep 2011 12:22:38 -0400 Subject: [PATCH] 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 --- Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD.pm | 6 ++++++ Open-ILS/src/perlmods/lib/OpenILS/Utils/MFHD/Caption.pm | 6 ++++++ 2 files changed, 12 insertions(+) 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; -- 2.43.2