[open-ils-commits] r18512 - branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Oct 27 16:21:21 EDT 2010


Author: erickson
Date: 2010-10-27 16:21:16 -0400 (Wed, 27 Oct 2010)
New Revision: 18512

Modified:
   branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
Log:
more micro-optimization of checkin code; protect against undef var warning in info message; removed unused sub

Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2010-10-27 20:20:29 UTC (rev 18511)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Circulate.pm	2010-10-27 20:21:16 UTC (rev 18512)
@@ -750,18 +750,24 @@
 		$patron = $e->search_actor_user([{card => $card->id}, $flesh])->[0]
 			or return $self->bail_on_events(OpenILS::Event->new('ACTOR_USER_NOT_FOUND'));
 
-	} else {
-		if( my $copy = $self->copy ) {
-			my $circs = $e->search_action_circulation(
-				{target_copy => $copy->id, checkin_time => undef});
+    } else {
+        if( my $copy = $self->copy ) {
 
-			if( my $circ = $circs->[0] ) {
-				$patron = $e->retrieve_actor_user([$circ->usr, $flesh])
-					or return $e->event;
-			}
-		}
-	}
+            $flesh->{flesh} = 2;
+            $flesh->{flesh_fields}->{circ} = ['usr'];
 
+            my $circ = $e->search_action_circulation([
+                {target_copy => $copy->id, checkin_time => undef}, $flesh
+            ])->[0];
+
+            if($circ) {
+                $patron = $circ->usr;
+                $circ->usr($patron->id); # de-flesh for consistency
+                $self->circ($circ); 
+            }
+        }
+    }
+
     return $self->bail_on_events(OpenILS::Event->new('ACTOR_USER_NOT_FOUND'))
         unless $self->patron($patron) or $self->is_checkin;
 
@@ -1808,7 +1814,7 @@
         my $dname = $duration->name;
         my $mname = $max->name;
         my $rname = $recurring->name;
-        my $hdname;
+        my $hdname = ''; 
         if($hard_due_date) {
             $hdname = $hard_due_date->name;
         }
@@ -2191,21 +2197,23 @@
         OpenILS::Event->new('ASSET_COPY_NOT_FOUND')) 
         unless $self->copy;
 
-    # the renew code will have already found our circulation object
-    unless( $self->is_renewal and $self->circ ) {
+    # the renew code and mk_env should have already found our circulation object
+    unless( $self->circ ) {
+
         my $circs = $self->editor->search_action_circulation(
             { target_copy => $self->copy->id, checkin_time => undef });
+
         $self->circ($$circs[0]);
 
         # for now, just warn if there are multiple open circs on a copy
         $logger->warn("circulator: we have ".scalar(@$circs).
             " open circs for copy " .$self->copy->id."!!") if @$circs > 1;
-
-        # run the fine generator against this circ, if this circ is there
-        $self->generate_fines_start if (@$circs);
     }
 
+    # run the fine generator against this circ, if this circ is there
+    $self->generate_fines_start if $self->circ;
 
+
     if( $self->checkin_check_holds_shelf() ) {
         $self->bail_on_events(OpenILS::Event->new('NO_CHANGE'));
         $self->hold($U->fetch_open_hold_by_copy($self->copy->id));
@@ -3078,19 +3086,6 @@
 }
 
 
-
-
-sub find_patron_from_copy {
-    my $self = shift;
-    my $circs = $self->editor->search_action_circulation(
-        { target_copy => $self->copy->id, checkin_time => undef });
-    my $circ = $circs->[0];
-    return unless $circ;
-    my $u = $self->editor->retrieve_actor_user($circ->usr)
-        or return $self->bail_on_events($self->editor->event);
-    $self->patron($u);
-}
-
 sub check_checkin_copy_status {
     my $self = shift;
    my $copy = $self->copy;



More information about the open-ils-commits mailing list