From 90a4c9d878a523cbc161d302be7bb23e8d82cab5 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Renvoize Signed-off-by: Joonas Kylmälä Signed-off-by: Jonathan Druart --- 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.39.5