Hi, The attached patch is a joint work with Katrin Fischer. She has found the bug, discovered what was wrong in the code and tested the patch.
Sébstien.
>From 9fbeecd35813ce259ef2253d332e01ba69303cae Mon Sep 17 00:00:00 2001 From: =?utf-8?q?S=C3=A9bastien=20Hinderer?= <[email protected]> Date: Sat, 17 Oct 2009 23:48:35 +0200 Subject: [PATCH] overdue_notices did not retrieve email addresses correctly. Content-Type: text/plain; charset="utf-8" The (not yet reported) bug fixed by this patch has been introduced by f1f833c96568284552dae2b12f14229ef5c991bc Indeed, that commit added a row to the select query which introduced a shift, because the rows where retrieved and assigned to variables with fetchrow_array. Now the code uses fetchrow_hashref, which shold make it more resistant to changes in the SQL request. --- misc/cronjobs/overdue_notices.pl | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-) mode change 100755 => 100644 misc/cronjobs/overdue_notices.pl diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl old mode 100755 new mode 100644 index 831cdfc..2b9bc4d --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -340,7 +340,7 @@ END_SQL # <date> <itemcount> <firstname> <lastname> <address1> <address2> <address3> <city> <postcode> my $borrower_sql = <<'END_SQL'; -SELECT COUNT(*), issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, MIN(date_due) as longest_issue +SELECT COUNT(*) as itemcount, issues.borrowernumber, firstname, surname, address, address2, city, zipcode, country, email, MIN(date_due) as longest_issue FROM issues,borrowers,categories WHERE issues.borrowernumber=borrowers.borrowernumber AND borrowers.categorycode=categories.categorycode @@ -369,7 +369,16 @@ END_SQL $sth->execute(@borrower_parameters); $verbose and warn $borrower_sql . "\n $branchcode | " . $overdue_rules->{'categorycode'} . "\n ($mindays, $maxdays)\nreturns " . $sth->rows . " rows"; - while( my ( $itemcount, $borrowernumber, $firstname, $lastname, $address1, $address2, $city, $postcode, $email ) = $sth->fetchrow ) { + while( my $row = $sth->fetchrow_hashref ) { + my $itemcount = $row->{'itemcount'}; + my $borrowernumber = $row->{'borrowernumber'}; + my $firstname = $row->{'firstname'}; + my $lastname = $row->{'surname'}; + my $address1 = $row->{'address'}; + my $address2 = $row->{'address2'}; + my $city = $row->{'city'}; + my $postcode = $row->{'zipcode'}; + my $email = $row->{'email'}; $verbose and warn "borrower $firstname, $lastname ($borrowernumber) has $itemcount items triggering level $i."; my $letter = C4::Letters::getletter( 'circulation', $overdue_rules->{"letter$i"} ); @@ -388,7 +397,7 @@ END_SQL $verbose and warn "debarring $borrowernumber $firstname $lastname\n"; } $sth2->execute( ($listall) ? ( $borrowernumber , 1 , $MAX ) : ( $borrowernumber, $mindays, $maxdays ) ); - my $itemcount = 0; + $itemcount = 0; my $titles = ""; while ( my $item_info = $sth2->fetchrow_hashref() ) { my @item_info = map { $_ =~ /^date|date$/ ? format_date( $item_info->{$_} ) : $item_info->{$_} || '' } @item_content_fields; -- 1.6.3.3
_______________________________________________ Koha-patches mailing list [email protected] http://lists.koha.org/mailman/listinfo/koha-patches
