From 6fdf64e06b5f6047eea22d431f9cf3095215bb72 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 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.39.5