From 0d5f47b12aba450bc1db4b27765852e6f5cc4f7f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 24 Aug 2022 16:30:43 +0100 Subject: [PATCH] Bug 31095: Remove GetDebarments from tools/modborrowers.pl This patch removes GetDebarments from the modborrowers tool controller and replaces it with $patron->restrictions as appropriate. Test plan 1. Confirm that the 'Batch patron modification' tool pages still load and perform as expected. Signed-off-by: Nick Clemens --- tools/modborrowers.pl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl index bb35b8e1c0..8a28815fbe 100755 --- a/tools/modborrowers.pl +++ b/tools/modborrowers.pl @@ -35,7 +35,7 @@ use Koha::DateUtils qw( dt_from_string ); use Koha::List::Patron qw( GetPatronLists ); use Koha::Libraries; use Koha::Patron::Categories; -use Koha::Patron::Debarments qw( AddDebarment DelDebarment GetDebarments ); +use Koha::Patron::Debarments qw( AddDebarment DelDebarment ); use Koha::Patrons; use List::MoreUtils qw(uniq); @@ -364,6 +364,7 @@ if ( $op eq 'do' ) { my @borrowernumbers = $input->multi_param('borrowernumber'); # For each borrower selected for my $borrowernumber ( @borrowernumbers ) { + # If at least one field are filled, we want to modify the borrower if ( defined $infos ) { # If a debarred date or debarred comment has been submitted make a new debarment @@ -378,19 +379,19 @@ if ( $op eq 'do' ) { } # If debarment date or debarment comment are disabled then remove all debarrments + my $patron = Koha::Patrons->find( $borrowernumber ); if ( grep { /debarred/ } @disabled ) { eval { - my $debarrments = GetDebarments( { borrowernumber => $borrowernumber } ); + my $debarrments = $patron->restrictions; foreach my $debarment (@$debarrments) { - DelDebarment( $debarment->{'borrower_debarment_id'} ); + DelDebarment( $debarment->borrower_debarment_id ); } }; } $infos->{borrowernumber} = $borrowernumber; - eval { Koha::Patrons->find( $borrowernumber )->set($infos)->store; }; + eval { $patron->set($infos)->store; }; if ( $@ ) { # FIXME We could provide better error handling here - my $patron = Koha::Patrons->find( $borrowernumber ); $infos->{cardnumber} = $patron ? $patron->cardnumber || '' : ''; push @errors, { error => "can_not_update", borrowernumber => $infos->{borrowernumber}, cardnumber => $infos->{cardnumber} }; } -- 2.20.1