some cleanup of the change_hold_title method
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 8 Feb 2010 20:18:12 +0000 (20:18 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 8 Feb 2010 20:18:12 +0000 (20:18 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15474 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm

index 327b63d..6f98016 100644 (file)
@@ -2354,30 +2354,27 @@ sub change_hold_title {
     my $e = new_editor(authtoken=>$auth, xact=>1);
     return $e->event unless $e->checkauth;
 
-    my $holds = $e->json_query({
-        "select"=>{"ahr"=>["id"]},
-        "from"=>"ahr",
-        "where"=>{
-            cancel_time => undef,
-            fulfillment_time => undef,
-            hold_type => 'T',
-            target => $bib_ids
+    my $holds = $e->search_action_hold_request(
+        [
+            {
+                cancel_time => undef,
+                fulfillment_time => undef,
+                hold_type => 'T',
+                target => $bib_ids
+            },{
+                flesh => 1, 
+                flesh_fields => {ahr => ['usr']}
+            }
+        ], {
+            substream => 1
         }
-    });
+    );
 
-    for my $hold_id (@$holds) {
-        my $hold = $e->retrieve_action_hold_request([$hold_id->{id}, {
-                flesh=> 1, 
-                flesh_fields=>{ahr=>['usr']}
-            }
-        ]);
-        $e->allowed('UPDATE_HOLD', $hold->usr->home_ou) or return $e->event;
+    for my $hold (@$holds) {
+        $e->allowed('UPDATE_HOLD', $hold->usr->home_ou) or return $e->die_event;
         $logger->info("Changing hold " . $hold->id . " target from " . $hold->target . " to $new_bib_id in title hold target change");
         $hold->target( $new_bib_id );
-        unless ($e->update_action_hold_request($hold)) {
-            my $evt = $e->event;
-            $logger->error("Error updating hold " . $evt->textcode . ":" . $evt->desc . ":" . $evt->stacktrace);
-        }
+        $e->update_action_hold_request($hold) or return $e->die_event;
     }
 
     $e->commit;