From 8695b7e84f22f0047e6d2204bc6248e6089c21f7 Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Fri, 23 Jan 2009 16:22:40 -0600 Subject: [PATCH] Prevent fines failure on NULL borrowernumber. The problem is that we do not ensure that the issues table has valid borrowernumber in each line. This is exacerbated by Getoverdues() returning data sorted BY borrowernumber. So one NULL borrowernumber in issues prevented ALL fines from being assessed. The actual error from fines.pl cron log is: No branchcode argument to new. Should be C4::Calendar->new(branchcode => $branchcode) at /home/user/kohaclone/misc/cronjobs/fines.pl line 98 This patch deals only with getting fines to avoid crashing. It does not fix the underlying data integrity problem. Signed-off-by: Galen Charlton --- misc/cronjobs/fines.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index 0e28357db3..de9e8cf7fb 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -89,6 +89,10 @@ for (my $i=0; $inew($data->[$i]->{'date_due'},'iso'); my $datedue_days = Date_to_Days(split(/-/,$datedue->output('iso'))); my $due_str = $datedue->output(); + unless (defined $data->[$i]->{'borrowernumber'}) { + print STDERR "ERROR in Getoverdues line $i: issues.borrowernumber IS NULL. Repair 'issues' table now! Skipping record.\n"; + next; # Note: this doesn't solve everything. After NULL borrowernumber, multiple issues w/ real borrowernumbers can pile up. + } my $borrower = BorType($data->[$i]->{'borrowernumber'}); my $branchcode = ($control eq 'ItemHomeLibrary') ? $data->[$i]->{homebranch} : ($control eq 'PatronLibrary' ) ? $borrower->{branchcode} : -- 2.20.1