Bug 25996: (follow-up) Log the entire object on deletion
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
38970ac9d6
commit
1a76cd4ec2
2 changed files with 16 additions and 11 deletions
|
@ -22,6 +22,7 @@ use Modern::Perl;
|
|||
use C4::Context;
|
||||
use C4::Log qw( logaction );
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::Patron::Restriction::Types;
|
||||
use Koha::Patron::Restrictions;
|
||||
|
||||
|
@ -102,20 +103,24 @@ Deletes a debarment.
|
|||
=cut
|
||||
|
||||
sub DelDebarment {
|
||||
my ($id) = @_;
|
||||
my ($borrower_debarment_id) = @_;
|
||||
|
||||
my $borrowernumber = _GetBorrowernumberByDebarmentId($id);
|
||||
my $restriction = Koha::Patron::Restrictions->find($borrower_debarment_id);
|
||||
|
||||
my $sql = "DELETE FROM borrower_debarments WHERE borrower_debarment_id = ?";
|
||||
return unless $restriction;
|
||||
|
||||
my $r = C4::Context->dbh->do( $sql, {}, ($id) );
|
||||
Koha::Database->new->schema->txn_do(
|
||||
sub {
|
||||
my $borrowernumber = $restriction->borrowernumber;
|
||||
logaction( "MEMBERS", "DELETE_RESTRICTION", $borrowernumber, $restriction )
|
||||
if C4::Context->preference("BorrowersLog");
|
||||
|
||||
UpdateBorrowerDebarmentFlags($borrowernumber);
|
||||
$restriction->delete;
|
||||
UpdateBorrowerDebarmentFlags($borrowernumber);
|
||||
}
|
||||
);
|
||||
|
||||
logaction( "MEMBERS", "DELETE_RESTRICTION", $borrowernumber, q{} )
|
||||
if C4::Context->preference("BorrowersLog");
|
||||
|
||||
return $r;
|
||||
return 1;
|
||||
}
|
||||
|
||||
=head2 ModDebarment
|
||||
|
|
|
@ -405,8 +405,8 @@ subtest 'BorrowersLog tests' => sub {
|
|||
is( $mod_logs->count, 1, 'Restriction modification logged' );
|
||||
like( $mod_logs->next->info, qr/$mod_comment/ );
|
||||
|
||||
is( $del_logs->count, 1, 'Restriction deletion logged' );
|
||||
is( $del_logs->next->info, q{}, 'Empty info field on deletion' );
|
||||
is( $del_logs->count, 1, 'Restriction deletion logged' );
|
||||
like( $del_logs->next->info, qr/$mod_comment/, 'Deleted restriction contains last known comment' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue