From 346f9424e5f8da74eca43a762b5b9f577c60d00a Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 4 Dec 2020 06:55:37 -0500 Subject: [PATCH] Bug 27145: Wrap delete and move_to_deleted in a transaction --- members/deletemem.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/members/deletemem.pl b/members/deletemem.pl index 4b2f091330..b07ff11278 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -128,11 +128,18 @@ if ( $op eq 'delete_confirm' or $countissues > 0 or $debits or $is_guarantor ) { session_id => $input->cookie('CGISESSID'), token => scalar $input->param('csrf_token'), }); + my $patron = Koha::Patrons->find( $member ); - $patron->move_to_deleted; + try { - $patron->delete; - print $input->redirect("/cgi-bin/koha/members/members-home.pl"); + my $schema = Koha::Database->new->schema; + $schema->txn_do( + sub { + $patron->move_to_deleted; + $patron->delete; + print $input->redirect( "/cgi-bin/koha/members/members-home.pl" ); + } + ); } catch { if ( $_->isa('Koha::Exceptions::Patron::FailedDeleteAnonymousPatron') ) { -- 2.24.1 (Apple Git-126)