From 6f8499eb5287d3a1b37791b441e061ac1ffdd49b Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Wed, 10 Apr 2019 14:39:40 +0100
Subject: [PATCH] Bug 22461: Clarify and correct the hash reduction

There were a couple of bugs in the previous patch which meant it wasn't
working as intended. This patch corrects those bugs and simplifies the
code a little along the way.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 C4/Auth_with_ldap.pm | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm
index 6def54d415..589dbcc68f 100644
--- a/C4/Auth_with_ldap.pm
+++ b/C4/Auth_with_ldap.pm
@@ -223,11 +223,9 @@ sub checkpw_ldap {
     } elsif ($config{replicate}) { # A2, C2
         my @columns = Koha::Patrons->columns;
         my $patron = Koha::Patron->new(
-            map {
-                grep join( ' ', @columns ) =~ /$_/
-                  ? ( $_ => $data{$_} )
-                  : ()
-            } keys %borrower
+            {
+                map { defined( $borrower{$_} ) ? ( $_ => $borrower{$_} ) : () } @columns
+            }
         )->store;
         die "Insert of new patron failed" unless $patron;
         $borrowernumber = $patron->borrowernumber;
-- 
2.20.1