From ac5e09a0f0564b437ab9b2aa47ebc3e1e35b796b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 18 Jun 2012 10:08:23 -0400 Subject: [PATCH] Bug 8267 - Overdue notices not working The variable $i was being re-used and overwriting the necessary value that was being passed to a subroutine. Renaming $i to $j fixed it. I also added an extra safety check within parse_letter that would also have prevented this bug. Signed-off-by: Julian Maurice Signed-off-by: Paul Poulain --- misc/cronjobs/overdue_notices.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 50d53d49dc..8c0bc12d30 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -486,14 +486,14 @@ END_SQL my $titles = ""; my @items = (); - my $i = 0; + my $j = 0; my $exceededPrintNoticesMaxLines = 0; while ( my $item_info = $sth2->fetchrow_hashref() ) { - if ( ( !$email || $nomail ) && $PrintNoticesMaxLines && $i >= $PrintNoticesMaxLines ) { + if ( ( !$email || $nomail ) && $PrintNoticesMaxLines && $j >= $PrintNoticesMaxLines ) { $exceededPrintNoticesMaxLines = 1; last; } - $i++; + $j++; my @item_info = map { $_ =~ /^date|date$/ ? format_date( $item_info->{$_} ) : $item_info->{$_} || '' } @item_content_fields; $titles .= join("\t", @item_info) . "\n"; $itemcount++; @@ -657,7 +657,7 @@ substituted keys and values. sub parse_letter { my $params = shift; foreach my $required (qw( letter_code borrowernumber )) { - return unless exists $params->{$required}; + return unless ( exists $params->{$required} && $params->{$required} ); } my $substitute = $params->{'substitute'} || {}; -- 2.39.5