From c1ef5545560ba1ad50f96db6514eb7a22507daca Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 15 Mar 2019 20:16:41 -0300 Subject: [PATCH] Bug 22461: Fix LDAP user replication From bug 20287: - $borrowernumber = C4::Members::AddMember(%borrower) or die "AddMember failed"; + Koha::Patron->new( \%borrower )->store; C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } ); $borrowernumber is not updated with the value of the newly created patron This patch restores the previous behavior (as well as the die) Signed-off-by: Martin Renvoize Signed-off-by: Alex Arnaud Signed-off-by: Nick Clemens (cherry picked from commit d482c7b27257f5a63425633a17efed0747c317a1) Signed-off-by: Martin Renvoize --- C4/Auth_with_ldap.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm index b5876a0d8d..931d6f45af 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -221,7 +221,9 @@ sub checkpw_ldap { return(1, $cardnumber, $local_userid); } } elsif ($config{replicate}) { # A2, C2 - Koha::Patron->new( \%borrower )->store; + my $patron = Koha::Patron->new( \%borrower )->store; + die "Insert of new patron failed" unless $patron; + $borrowernumber = $patron->borrowernumber; C4::Members::Messaging::SetMessagingPreferencesFromDefaults( { borrowernumber => $borrowernumber, categorycode => $borrower{'categorycode'} } ); } else { return 0; # B2, D2 -- 2.39.5