From 80d5c4a4c7e81a7b5739befdd5a621a70d42d5f0 Mon Sep 17 00:00:00 2001
From: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Date: Wed, 19 Oct 2011 18:16:14 -0400
Subject: [PATCH] TPAC: avoid problem with HOLD_EXISTS event in hold placement

If you place a hold on something that generates a HOLD_EXISTS event (and
no other events?) you get a 500 error from Apache and an error in the
logs saying "not a hash reference" about $result in the lines I've
changed here.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
---
 Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
index a532bffc91..59bc862dd5 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
@@ -695,7 +695,13 @@ sub load_place_hold {
                 } else {
                     # hold-specific failure event 
                     $hdata->{hold_failed} = 1;
-                    $hdata->{hold_failed_event} = $result->{last_event};
+
+                    if (ref $result eq 'HASH') {
+                        $hdata->{hold_failed_event} = $result->{last_event};
+                    } elsif (ref $result eq 'ARRAY') {
+                        $hdata->{hold_failed_event} = pop @$result;
+                    }
+
                     $hdata->{could_override} = $self->test_could_override($hdata->{hold_failed_event});
                 }
             }
-- 
2.11.0