diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm index 4af3cd6db2..db77a3be7b 100644 --- a/Koha/Patrons/Import.pm +++ b/Koha/Patrons/Import.pm @@ -167,7 +167,7 @@ sub import_patrons { if ( defined($matchpoint) && ( $matchpoint eq 'cardnumber' ) && ( $borrower{'cardnumber'} ) ) { $member = Koha::Patrons->find( { cardnumber => $borrower{'cardnumber'} } ); } - elsif ( ($matchpoint eq 'userid') && ($borrower{'userid'}) ) { + elsif ( defined($matchpoint) && ($matchpoint eq 'userid') && ($borrower{'userid'}) ) { $member = Koha::Patrons->find( { userid => $borrower{userid} } ); } elsif ($extended) { @@ -201,7 +201,7 @@ sub import_patrons { } # Check if the userid provided does not exist yet - if ( $matchpoint ne 'userid' and exists $borrower{userid} + if ( defined($matchpoint) and $matchpoint ne 'userid' and exists $borrower{userid} and $borrower{userid} and not Check_Userid( $borrower{userid}, $borrower{borrowernumber} ) ) { push @errors, { duplicate_userid => 1, userid => $borrower{userid} }; diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t index 4e4bde49f5..e5738bb021 100644 --- a/t/db_dependent/Koha/Patrons/Import.t +++ b/t/db_dependent/Koha/Patrons/Import.t @@ -317,7 +317,6 @@ subtest 'test_prepare_columns' => sub { plan tests => 16; # Given ... no header row - my $headerrow_0; my %csvkeycol_0; my @errors_0;