From 6c07ae2c042ff19dfde5b700f06ea856de8e7d9e Mon Sep 17 00:00:00 2001 From: Hayley Mapley Date: Mon, 6 May 2019 13:58:22 +1200 Subject: [PATCH] Bug 20537: Added checks to remove warning from overdue_notices.pl When executing overdue_notices.pl on borrowers that lack a surname, we see this error: Use of uninitialized value in concatenation (.) or string at /usr/share/koha/bin/cronjobs/overdue_notices.pl line 575. This patch fixes this issue by setting the $borr variable based on the information that has been defined. To test: 1) Create a borrower and set its surname to null 2) Checkout an item to the borrower and set it to be overdue 3) Navigate to kohaclone/misc/cronjobs and enter a koha-shell 4) Run the script: ./overdue_notices.pl 5) Observe the error appears 6) Apply the patch 7) Repeat steps 3-4 8) Observe the error is gone 9) Sign off! Sponsored-by: Catalyst IT --- misc/cronjobs/overdue_notices.pl | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 3ab07b42da..e419cab1c1 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -575,21 +575,11 @@ END_SQL } $borrowernumber = $data->{'borrowernumber'}; - my $borr; - if ($data->{'surname'} && $data->{'firstname'}) { - $borr = - $data->{'firstname'} . ', ' - . $data->{'surname'} . ' (' - . $borrowernumber . ')'; - } elsif ($data->{'surname'}) { - $borr = - $data->{'surname'} . ' (' - . $borrowernumber . ')'; - } elsif ($data->{'firstname'}) { - $borr = - $data->{'firstname'} . ' (' - . $borrowernumber . ')'; - } + my $borr = sprintf( "%s%s%s (%s)", + $data->{'surname'} || '', + $data->{'firstname'} && $data->{'surname'} ? ', ' : '', + $data->{'firstname'} || '', + $borrowernumber ); $verbose and warn "borrower $borr has items triggering level $i."; -- 2.11.0