LP 1779467: Fix Error When Marking Item on Hold as Discard/Weed
authorJason Stephenson <jason@sigio.com>
Mon, 12 Nov 2018 14:17:11 +0000 (09:17 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Tue, 15 Jan 2019 16:52:01 +0000 (11:52 -0500)
Fix the following error when marking an on-hold item as Discard/Weed:

Can't use an undefined value as an ARRAY reference at
/usr/local/share/perl/5.18.2/OpenILS/Application/Circ.pm line 1393.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm

index f3cec22..0dfebd3 100644 (file)
@@ -1376,21 +1376,21 @@ sub mark_item {
     return $evt if $evt;
 
     # Retrieving holds for later use.
-    my $holds = $e->search_action_hold_request(
+    my $holds = $e->search_action_hold_request([
         {
             current_copy => $copy->id,
             fulfillment_time => undef,
             cancel_time => undef,
         },
         {flesh=>1, flesh_fields=>{ahr=>['eligible_copies']}}
-    );
+    ]);
 
     # Throw event if attempting to  mark discard the only copy to fill a hold.
     if ($self->api_name =~ /discard/) {
         if (!$args->{handle_last_hold_copy}) {
             for my $hold (@$holds) {
                 my $eligible = $hold->eligible_copies();
-                if (scalar(@{$eligible}) < 2) {
+                if (!defined($eligible) || scalar(@{$eligible}) < 2) {
                     $evt = OpenILS::Event->new('ITEM_TO_MARK_LAST_HOLD_COPY');
                     last;
                 }