From e2f6ee978e8ad0c4da376cdd413aa9fdc69c5597 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 8 Dec 2025 18:34:36 +0000 Subject: [PATCH] Bug 41404: Use looks_like_a_number to verify if prefs are set This check adds a check to ensure we have number, not just defined To test: 1 - Apply only unit tests patch 2 - Run the tests prove -v t/db_dependent/Koha/Patron.t 3 - Apply this patch 4 - Run the tests 5 - They pass! Signed-off-by: David Nind --- Koha/Patron.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 03276ff6a5..8da13cecfc 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -22,6 +22,7 @@ use Modern::Perl; use List::MoreUtils qw( any none uniq notall zip6); use JSON qw( to_json ); +use Scalar::Util qw(looks_like_number); use Unicode::Normalize qw( NFKD ); use Try::Tiny; use DateTime (); @@ -3519,7 +3520,7 @@ sub is_patron_inside_charge_limits { my $guarantors_non_issues_charges = 0; # Check the debt of this patrons guarantees - if ( defined $no_issues_charge_guarantees ) { + if ( defined $no_issues_charge_guarantees && looks_like_number($no_issues_charge_guarantees) ) { my @guarantees = map { $_->guarantee } $patron->guarantee_relationships->as_list; foreach my $g (@guarantees) { $guarantees_non_issues_charges += $g->account->non_issues_charges; @@ -3527,7 +3528,9 @@ sub is_patron_inside_charge_limits { } # Check the debt of this patrons guarantors *and* the guarantees of those guarantors - if ( defined $no_issues_charge_guarantors_with_guarantees ) { + if ( defined $no_issues_charge_guarantors_with_guarantees + && looks_like_number($no_issues_charge_guarantors_with_guarantees) ) + { $guarantors_non_issues_charges = $patron->relationships_debt( { include_guarantors => 1, only_this_guarantor => 0, include_this_patron => 1 } ); } -- 2.39.5