Bug 8267 - Overdue notices not working
authorKyle M Hall <kyle@bywatersolutions.com>
Mon, 18 Jun 2012 14:08:23 +0000 (10:08 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Wed, 20 Jun 2012 21:14:56 +0000 (23:14 +0200)
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 <julian.maurice@biblibre.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
misc/cronjobs/overdue_notices.pl

index 50d53d4..8c0bc12 100755 (executable)
@@ -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'} || {};