Bugzilla – Attachment 144912 Details for
Bug 31095
Remove Koha::Patron::Debarment::GetDebarments and use $patron->restrictions in preference
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31095: Remove GetDebarments from Circulation.pm
Bug-31095-Remove-GetDebarments-from-Circulationpm.patch (text/plain), 3.05 KB, created by
Jonathan Druart
on 2023-01-02 14:59:07 UTC
(
hide
)
Description:
Bug 31095: Remove GetDebarments from Circulation.pm
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-01-02 14:59:07 UTC
Size:
3.05 KB
patch
obsolete
>From 337a031c051bc0bd0fb0e128e6f2e84b0f778025 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 24 Aug 2022 16:47:54 +0100 >Subject: [PATCH] Bug 31095: Remove GetDebarments from Circulation.pm > >This patch removes GetDebarments from Circulation.pm replacing them with >calls to $patron->restrictions and filtering using a chained search >call. > >Test plan >1. Confirm that t/db_dependant/Circulation.t continues to pass > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > C4/Circulation.pm | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 336ce9490a1..82aaccf3342 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -48,7 +48,7 @@ use Koha::Checkouts; > use Koha::Illrequests; > use Koha::Items; > use Koha::Patrons; >-use Koha::Patron::Debarments qw( DelUniqueDebarment GetDebarments AddUniqueDebarment ); >+use Koha::Patron::Debarments qw( DelUniqueDebarment AddUniqueDebarment ); > use Koha::Database; > use Koha::Libraries; > use Koha::Account::Lines; >@@ -2540,10 +2540,11 @@ sub MarkIssueReturned { > } > > # Remove any OVERDUES related debarment if the borrower has no overdues >+ my $overdue_restrictions = $patron->restrictions->search({ type => 'OVERDUES' }); > if ( C4::Context->preference('AutoRemoveOverduesRestrictions') > && $patron->debarred > && !$patron->has_overdues >- && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) } >+ && $overdue_restrictions->count > ) { > DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' }); > } >@@ -2632,9 +2633,10 @@ sub _calculate_new_debar_dt { > > my ( $has_been_extended ); > if ( C4::Context->preference('CumulativeRestrictionPeriods') and $borrower->{debarred} ) { >- my $debarment = @{ GetDebarments( { borrowernumber => $borrower->{borrowernumber}, type => 'SUSPENSION' } ) }[0]; >+ my $patron = Koha::Patrons->find($borrower->{borrowernumber}); >+ my $debarment = $patron->restrictions->search({type => 'SUSPENSION' },{rows => 1})->single; > if ( $debarment ) { >- $return_date = dt_from_string( $debarment->{expiration}, 'sql' ); >+ $return_date = dt_from_string( $debarment->expiration, 'sql' ); > $has_been_extended = 1; > } > } >@@ -3171,10 +3173,11 @@ sub AddRenewal { > } > > # Remove any OVERDUES related debarment if the borrower has no overdues >+ my $overdue_restrictions = $patron->restrictions->search({ type => 'OVERDUES' }); > if ( $patron > && $patron->is_debarred > && ! $patron->has_overdues >- && @{ GetDebarments({ borrowernumber => $borrowernumber, type => 'OVERDUES' }) } >+ && $overdue_restrictions->count > ) { > DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' }); > } >-- >2.25.1
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 31095
:
139614
|
139719
|
139720
|
139721
|
139722
|
139723
|
139724
|
139725
|
139726
|
139727
|
139728
|
139742
|
139743
|
139744
|
139745
|
139746
|
139747
|
139748
|
139749
|
139750
|
139751
|
139752
|
139753
|
139754
|
139755
|
139756
|
139757
|
139758
|
140714
|
140715
|
140716
|
140717
|
140718
|
140719
|
140720
|
140721
|
140722
|
140723
|
140724
|
140725
|
140726
|
140727
|
140728
|
140729
|
140730
|
140731
|
142059
|
142060
|
142061
|
142062
|
142063
|
142064
|
142065
|
142066
|
142067
|
142068
|
142069
|
142070
|
142071
|
142072
|
142073
|
142074
|
142075
|
142076
|
143745
|
143746
|
143747
|
143748
|
143749
|
143750
|
143751
|
143752
|
143753
|
143754
|
143755
|
143756
|
143757
|
143758
|
143759
|
143760
|
143761
|
143762
|
143763
|
144903
|
144904
|
144905
|
144906
|
144907
|
144908
|
144909
|
144910
|
144911
| 144912 |
144913
|
144914
|
144915
|
144916
|
144917
|
144918
|
144919
|
144920
|
144921
|
145800
|
145801
|
145803
|
145845