From 2c9aba48dc5181bafee7215a4577e6ff2af2cdf7 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Fri, 8 Aug 2008 12:15:10 -0500 Subject: [PATCH] Fix to prevent crash on null dateexpiry. Error was: Usage: Date::Calc::Date_to_Days(year, month, day) Signed-off-by: Joshua Ferraro --- reserve/request.pl | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/reserve/request.pl b/reserve/request.pl index fd35b9b8b9..eb41244959 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -93,7 +93,6 @@ if ($findborrower) { if ($cardnumber) { my $borrowerinfo = GetMemberDetails( 0, $cardnumber ); - my $expiry; my $diffbranch; my @getreservloop; my $count_reserv = 0; @@ -110,16 +109,11 @@ if ($cardnumber) { $maxreserves = 1; } - # we check the date expiricy of the borrower (only if there is an expiry date, otherwise, set to 1 (warn) - if ($borrowerinfo->{'dateexpiry'} ne '0000-00-00') { - my $warning = (Date_to_Days(split /-/,$date) > Date_to_Days( split /-/,$borrowerinfo->{'dateexpiry'})); - if ( $warning > 0 ) { - $messages = 1; - $expiry = 1; - } - } else { - $messages = 1; - $expiry = 1; + # we check the date expiry of the borrower (only if there is an expiry date, otherwise, set to 1 (warn) + my $expiry = $borrowerinfo->{dateexpiry}; + unless ($expiry and $expiry ne '0000-00-00' and + Date_to_Days(split /-/,$date) > Date_to_Days(split /-/,$expiry)) { + $messages = $expiry = 1; } -- 2.39.5