From be0bf8731a2361f4fabbfff8059fef60dd364d88 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 10 Aug 2017 15:20:43 -0300 Subject: [PATCH] Bug 19074: Do not crash if cardnumber does not exist If a cardnumber does not exist, $borrower will be undef and the ->category call will explode Can't call method "category" on an undefined value at /home/vagrant/kohaclone/tools/modborrowers.pl line 370. This patch makes sure the patron exists before calling any methods. Signed-off-by: Jonathan Druart Signed-off-by: Jonathan Druart --- tools/modborrowers.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/modborrowers.pl b/tools/modborrowers.pl index 7acc9a8a33..3b83f2bb35 100755 --- a/tools/modborrowers.pl +++ b/tools/modborrowers.pl @@ -366,10 +366,10 @@ exit; sub GetBorrowerInfos { my ( %info ) = @_; - my $borrower = Koha::Patrons->find( \%info ); - my $catdesc = $borrower->category->description; - if ( $borrower ) { - $borrower = $borrower->unblessed; + my $patron = Koha::Patrons->find( \%info ); + my $borrower; + if ( $patron ) { + $borrower = $patron->unblessed; for ( qw(dateenrolled dateexpiry) ) { my $userdate = $borrower->{$_}; unless ($userdate && $userdate ne "0000-00-00" and $userdate ne "9999-12-31") { @@ -378,7 +378,7 @@ sub GetBorrowerInfos { } $borrower->{$_} = $userdate || ''; } - $borrower->{category_description} = $catdesc; + $borrower->{category_description} = $patron->category->description; my $attr_loop = C4::Members::Attributes::GetBorrowerAttributes( $borrower->{borrowernumber} ); $borrower->{patron_attributes} = $attr_loop; } -- 2.39.5