Bugzilla – Attachment 165281 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: Make AddDebarment() use Koha::Patron::Restriction
Bug-25996-Make-AddDebarment-use-KohaPatronRestrict.patch (text/plain), 2.31 KB, created by
ByWater Sandboxes
on 2024-04-22 13:17:44 UTC
(
hide
)
Description:
Bug 25996: Make AddDebarment() use Koha::Patron::Restriction
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2024-04-22 13:17:44 UTC
Size:
2.31 KB
patch
obsolete
>From 71e0267af91551a19392a568a57eb7188df92df8 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 22 Apr 2024 00:07:30 -0300 >Subject: [PATCH] Bug 25996: Make AddDebarment() use Koha::Patron::Restriction > >This patch makes the AddDebarment() method use the Koha::Object-based >class to ease the next steps. The current codebase makes the feature >fragile otherwise, as adding a new row and then querying for the latest >row of that kind seems risky, > >With this approach the result is the same, but we have the >Koha::Patron::Restriction object for using it later in logging. > >I opted to return 1 as it does now. The whole module deserves to be >removed in the future but it is out of the scope of this report. > >To test: >1. Run: > $ ktd --shell > k$ prove t/db_dependent/Patron/Borrower_Debarments.t >=> SUCCESS: Tests pass >2. Apply this tiny refactoring patch >3. Repeat 1 >=> SUCCESS: Tests still pass! >4. Sign off :-D > >Sponsored-by: Karlsruhe Institute of Technology (KIT) >Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu> >--- > Koha/Patron/Debarments.pm | 18 +++++++++++------- > 1 file changed, 11 insertions(+), 7 deletions(-) > >diff --git a/Koha/Patron/Debarments.pm b/Koha/Patron/Debarments.pm >index e866dc2ea7..2ac587307f 100644 >--- a/Koha/Patron/Debarments.pm >+++ b/Koha/Patron/Debarments.pm >@@ -22,6 +22,7 @@ use Modern::Perl; > use C4::Context; > > use Koha::Patron::Restriction::Types; >+use Koha::Patron::Restrictions; > > our ( @ISA, @EXPORT_OK ); > >@@ -73,16 +74,19 @@ sub AddDebarment { > my $manager_id; > $manager_id = C4::Context->userenv->{'number'} if C4::Context->userenv; > >- my $sql = " >- INSERT INTO borrower_debarments ( borrowernumber, expiration, type, comment, manager_id, created ) >- VALUES ( ?, ?, ?, ?, ?, NOW() ) >- "; >- >- my $r = C4::Context->dbh->do( $sql, {}, ( $borrowernumber, $expiration, $type, $comment, $manager_id ) ); >+ my $restriction = Koha::Patron::Restriction->new( >+ { >+ borrowernumber => $borrowernumber, >+ expiration => $expiration, >+ type => $type, >+ comment => $comment, >+ manager_id => $manager_id, >+ } >+ )->store(); > > UpdateBorrowerDebarmentFlags($borrowernumber); > >- return $r; >+ return $restriction ? 1 : 0; > } > > =head2 DelDebarment >-- >2.39.2
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