TPAC: avoid problem with HOLD_EXISTS event in hold placement
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Wed, 19 Oct 2011 22:16:14 +0000 (18:16 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 19 Oct 2011 22:26:58 +0000 (18:26 -0400)
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

index a532bff..59bc862 100644 (file)
@@ -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});
                 }
             }