Bugzilla – Attachment 166060 Details for
Bug 25996
Changes to restrictions should be logged
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25996: (follow-up) Log the entire object on deletion
Bug-25996-follow-up-Log-the-entire-object-on-delet.patch (text/plain), 2.68 KB, created by
Martin Renvoize (ashimema)
on 2024-05-02 10:58:35 UTC
(
hide
)
Description:
Bug 25996: (follow-up) Log the entire object on deletion
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-05-02 10:58:35 UTC
Size:
2.68 KB
patch
obsolete
>From c058dd3dabcbc99a20837e012fac0ad6bde5bb7b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 22 Apr 2024 08:26:46 -0300 >Subject: [PATCH] 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> >--- > Koha/Patron/Debarments.pm | 23 +++++++++++++-------- > t/db_dependent/Patron/Borrower_Debarments.t | 4 ++-- > 2 files changed, 16 insertions(+), 11 deletions(-) > >diff --git a/Koha/Patron/Debarments.pm b/Koha/Patron/Debarments.pm >index 8890fedf4f2..8512342a4ba 100644 >--- a/Koha/Patron/Debarments.pm >+++ b/Koha/Patron/Debarments.pm >@@ -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 $borrowernumber = _GetBorrowernumberByDebarmentId($id); >+ my ($borrower_debarment_id) = @_; > >- my $sql = "DELETE FROM borrower_debarments WHERE borrower_debarment_id = ?"; >+ my $restriction = Koha::Patron::Restrictions->find($borrower_debarment_id); > >- my $r = C4::Context->dbh->do( $sql, {}, ($id) ); >+ return unless $restriction; > >- UpdateBorrowerDebarmentFlags($borrowernumber); >+ Koha::Database->new->schema->txn_do( >+ sub { >+ my $borrowernumber = $restriction->borrowernumber; >+ logaction( "MEMBERS", "DELETE_RESTRICTION", $borrowernumber, $restriction ) >+ if C4::Context->preference("BorrowersLog"); > >- logaction( "MEMBERS", "DELETE_RESTRICTION", $borrowernumber, q{} ) >- if C4::Context->preference("BorrowersLog"); >+ $restriction->delete; >+ UpdateBorrowerDebarmentFlags($borrowernumber); >+ } >+ ); > >- return $r; >+ return 1; > } > > =head2 ModDebarment >diff --git a/t/db_dependent/Patron/Borrower_Debarments.t b/t/db_dependent/Patron/Borrower_Debarments.t >index 84d3250cdce..ae47365a9bd 100755 >--- a/t/db_dependent/Patron/Borrower_Debarments.t >+++ b/t/db_dependent/Patron/Borrower_Debarments.t >@@ -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; > }; >-- >2.44.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25996
:
165244
|
165245
|
165246
|
165247
|
165267
|
165281
|
165282
|
165283
|
165284
|
165285
|
166056
|
166057
|
166058
|
166059
| 166060