From d482c7b27257f5a63425633a17efed0747c317a1 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 --- 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 d9841a88a0..3e2ab5cb86 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