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>
This commit is contained in:
Kyle Hall 2020-12-04 06:55:37 -05:00 committed by Jonathan Druart
parent 83dcdf2a5a
commit 6fdf64e06b

View file

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