From b0c402c8c9ada083facf7f5a98982da36d3ab1e2 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 Signed-off-by: Martin Renvoize --- members/deletemem.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/members/deletemem.pl b/members/deletemem.pl index 4b31e1d76a..5faf87dc47 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -127,11 +127,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.20.1