Lp 1661688: Fix undefined value error in Circulate.pm.
authorJason Stephenson <jason@sigio.com>
Fri, 15 Dec 2017 16:21:43 +0000 (11:21 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Wed, 28 Feb 2018 21:48:58 +0000 (16:48 -0500)
We needed to check that there was a hold before picking out the hold
usr.

Also, fix an error in the flesh code added by this branch.  We don't
need to flesh text fields from actor.usr.

Signed-off-by: Jason Stephenson <jason@sigio.com>
Signed-off-by: Dan Pearl <dpearl@cwmars.org>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Circulate.pm

index f516381..caed8bb 100644 (file)
@@ -1120,10 +1120,8 @@ sub check_captured_holds {
                 fulfillment_time    => undef 
             },
             { limit => 1,
-              flesh => 2,
-              flesh_fields => { ahr => ['usr'],
-                                au => ['family_name', 'first_given_name']
-             }
+              flesh => 1,
+              flesh_fields => { ahr => ['usr'] }
             }
         ]
     )->[0];
@@ -1131,21 +1129,22 @@ sub check_captured_holds {
     if ($hold and $hold->usr == $patron->id) {
         $self->checkout_is_for_hold(1);
         return undef;
+    } elsif ($hold) {
+        my $payload;
+        my $holdau = $hold->usr;
+
+        if ($holdau) {
+            $payload->{patron_name} = $holdau->first_given_name . ' ' . $holdau->family_name;
+        } else {
+            $payload->{patron_name} = "???";
+        }
+        $payload->{hold_id}     = $hold->id;
+        $self->push_events(OpenILS::Event->new('ITEM_ON_HOLDS_SHELF',
+                                               payload => $payload));
     }
 
     $logger->info("circulator: this copy is needed by a different patron to fulfill a hold");
 
-    my $payload;
-    my $holdau = $hold->usr;
-
-    if ($holdau) {
-       $payload->{patron_name} = $holdau->first_given_name . ' ' . $holdau->family_name;
-    } else {
-       $payload->{patron_name} = "???";
-    }
-    $payload->{hold_id}     = $hold->id;
-    $self->push_events(OpenILS::Event->new('ITEM_ON_HOLDS_SHELF',
-           payload => $payload));
 }