moving another hold fetch inside a xact block
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 21 Jan 2007 19:03:42 +0000 (19:03 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 21 Jan 2007 19:03:42 +0000 (19:03 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0@6796 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm

index 0ebb08d..14c1b24 100644 (file)
@@ -687,6 +687,7 @@ sub new_hold_copy_targeter {
 
        try {
                if ($one_hold) {
+                       $self->method_lookup('open-ils.storage.transaction.begin')->run( $client );
                        $holds = [ action::hold_request->search_where( { id => $one_hold, fulfillment_time => undef, cancel_time => undef } ) ];
                } elsif ( $check_expire ) {
 
@@ -744,10 +745,6 @@ sub new_hold_copy_targeter {
 
        for my $hold (@$holds) {
                try {
-                       #first, re-fetch the hold, to make sure it's not captured already
-                       $hold = action::hold_request->retrieve( $hold->id );
-                       die "OK\n" if (!$hold or $hold->capture_time);
-
                        #start a transaction if needed
                        if ($self->method_lookup('open-ils.storage.transaction.current')->run) {
                                $log->debug("Cleaning up after previous transaction\n");
@@ -756,6 +753,10 @@ sub new_hold_copy_targeter {
                        $self->method_lookup('open-ils.storage.transaction.begin')->run( $client );
                        $log->info("Processing hold ".$hold->id."...\n");
 
+                       #first, re-fetch the hold, to make sure it's not captured already
+                       $hold = action::hold_request->retrieve( $hold->id );
+                       die "OK\n" if (!$hold or $hold->capture_time);
+
                        # remove old auto-targeting maps
                        my @oldmaps = action::hold_copy_map->search( hold => $hold->id );
                        $_->delete for (@oldmaps);