From cbfb1c281ab0826eb3ae3dd1980eed694eee9c8d Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Wed, 21 Feb 2018 16:10:30 -0300
Subject: [PATCH] Bug 19936: Replace Check_userid - Update the occurrences

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
---
 Koha/Patrons/Import.pm | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/Koha/Patrons/Import.pm b/Koha/Patrons/Import.pm
index a8d17c1..fbf9701 100644
--- a/Koha/Patrons/Import.pm
+++ b/Koha/Patrons/Import.pm
@@ -200,13 +200,17 @@ sub import_patrons {
             next;
         }
 
+
         # Check if the userid provided does not exist yet
-        if ( defined($matchpoint) and $matchpoint ne 'userid' and exists $borrower{userid}
-                 and $borrower{userid}
-             and ( $patron and not $patron->userid($borrower{userid})->has_valid_userid ) ) {
-             push @errors, { duplicate_userid => 1, userid => $borrower{userid} };
-             $invalid++;
-             next LINE;
+        if (    defined($matchpoint)
+            and $matchpoint ne 'userid'
+            and exists $borrower{userid}
+            and $borrower{userid}
+            and not Koha::Patron->new( { userid => $borrower{userid} } )->has_valid_userid
+        ) {
+            push @errors, { duplicate_userid => 1, userid => $borrower{userid} };
+            $invalid++;
+            next LINE;
         }
 
         if ($borrowernumber) {
-- 
2.1.4