make payment receipt print/email run inside a transaction. instead of using authorit...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 16 Mar 2011 18:19:20 +0000 (18:19 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 16 Mar 2011 18:19:20 +0000 (18:19 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@19782 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Money.pm

index a88cdac..460244a 100644 (file)
@@ -520,8 +520,12 @@ sub format_payment_receipt {
 
     my $for_print = ($self->api_name =~ /print/);
     my $for_email = ($self->api_name =~ /email/);
-    my $e = new_editor(authtoken => $auth);
-    return $e->event unless $e->checkauth;
+
+    # manually use xact (i.e. authoritative) so we can kill the cstore
+    # connection before sending the action/trigger request.  This prevents our cstore
+    # backend from sitting idle while A/T (which uses its own transactions) runs.
+    my $e = new_editor(xact => 1, authtoken => $auth);
+    return $e->die_event unless $e->checkauth;
 
     my $payments = [];
     for my $id (@$mp_ids) {
@@ -534,15 +538,17 @@ sub format_payment_receipt {
                     mbt => ['usr']
                 }
             }
-        ]) or return $e->event;
+        ]) or return $e->die_event;
 
-        return $e->event unless 
+        return $e->die_event unless 
             $e->requestor->id == $payment->xact->usr->id or
             $e->allowed('VIEW_TRANSACTION', $payment->xact->usr->home_ou); 
 
         push @$payments, $payment;
     }
 
+    $e->rollback;
+
     if ($for_print) {
 
         return $U->fire_object_event(undef, 'money.format.payment_receipt.print', $payments, $$payments[0]->xact->usr->home_ou);