From 78d0120157020ffd98eb202a0bca80a432bc49de Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sat, 8 Jan 2022 14:01:43 -0500 Subject: [PATCH] Use savepoint for aci update --- .../src/perlmods/lib/OpenILS/Application/Circ.pm | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm index 23f99d438b..7e57a65677 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm @@ -376,19 +376,35 @@ __PACKAGE__->register_method( sub update_copy_inventory { my( $self, $conn, $auth, $args ) = @_; - my $e = new_editor(authtoken=>$auth, xact=>1); - return $e->die_event unless $e->checkauth; + my $e = new_editor(authtoken=>$auth); + return [0, 0, $e->die_event] unless $e->checkauth; + my ($success,$failure) = (0,0); + + $e->xact_begin(); my $copies = $$args{copy_list}; foreach my $copyid (@$copies) { my $aci = Fieldmapper::asset::copy_inventory->new; $aci->inventory_date('now'); $aci->inventory_workstation($e->requestor->wsid); $aci->copy($copyid); - $e->create_asset_copy_inventory($aci) or return $e->die_event; + my $spname = "aci_savepoint${success}"; + $e->set_savepoint($spname); + if ($e->create_asset_copy_inventory($aci)) { + $success++; + } else { + $failure++; + $e->rollback_savepoint($spname); + } + $e->release_savepoint($spname); } - $e->commit; - return 1; + if ($success) { + $e->commit(); + } else { + $e->rollback(); + } + + return [ $success, $failure ]; } __PACKAGE__->register_method( -- 2.11.0