Bug 27145: Wrap delete and move_to_deleted in a transaction

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit 90a4c9d878)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Kyle M Hall 2020-12-04 06:55:37 -05:00 committed by Fridolin Somers
parent 8bcf0dfaf3
commit 5d9b4aa7f3
1 changed files with 10 additions and 3 deletions

View File

@ -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') ) {