From 246a0f600cad55783c9a86652d140e14575af7b3 Mon Sep 17 00:00:00 2001
From: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Date: Tue, 21 Apr 2020 13:50:30 +0000
Subject: [PATCH] Bug 25220: maxoutstanding ignored if null in opac-reserve.pl
To Test:
1) set maxoutstanding to empty
2) give yourself a fine of $1
3) try to place a hold on the opac
4) confirm you cannot place hold
5) apply patch, restart_all
6) reload opac
7) confirm hold is allowed
8) set maxoutstanding to $2
9) confirm hold is now blocked
---
opac/opac-reserve.pl | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index 2a11ad48e5..b1fbc155a2 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -45,6 +45,8 @@ use Koha::Patrons;
use Date::Calc qw/Today Date_to_Days/;
use List::MoreUtils qw/uniq/;
+use Scalar::Util qw(looks_like_number);
+
my $maxreserves = C4::Context->preference("maxreserves");
my $query = new CGI;
@@ -339,9 +341,10 @@ if ( $query->param('place_reserve') ) {
#
my $noreserves = 0;
my $maxoutstanding = C4::Context->preference("maxoutstanding");
+$maxoutstanding = undef unless looks_like_number($maxoutstanding);
$template->param( noreserve => 1 ) unless $maxoutstanding;
my $amountoutstanding = $patron->account->balance;
-if ( $amountoutstanding && ($amountoutstanding > $maxoutstanding) ) {
+if ( $amountoutstanding && defined($maxoutstanding) && ($amountoutstanding > $maxoutstanding) ) {
my $amount = sprintf "%.02f", $amountoutstanding;
$template->param( message => 1 );
$noreserves = 1;
--
2.11.0