From 8b4f2db7ef41964b522a58fba6b4601c42f93069 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 25 May 2021 10:34:49 +0200 Subject: [PATCH] Bug 28385: Use ldapserver only if exists Fix test t/db_dependent/Auth_with_ldap.t .. 1/4 # Failed test 'use C4::Auth_with_ldap;' # at t/db_dependent/Auth_with_ldap.t line 123. # Tried to use 'C4::Auth_with_ldap'. # Error: No ldapserver "id="ldapserver"" defined in KOHA_CONF: /etc/koha/sites/kohadev/koha-conf.xml at /kohadevbox/koha/C4/Auth_with_ldap.pm line 55. # Compilation failed in require at t/db_dependent/Auth_with_ldap.t line 123. # BEGIN failed--compilation aborted at t/db_dependent/Auth_with_ldap.t line 123. Signed-off-by: Jonathan Druart --- 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 face1e428f..c87ea20c93 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -52,7 +52,9 @@ sub ldapserver_error { use vars qw($mapping @ldaphosts $base $ldapname $ldappassword); my $ldap = C4::Context->config("ldapserver") or die 'No "ldapserver" in server hash from KOHA_CONF: ' . $ENV{KOHA_CONF}; # since Bug 28278 we need to skip id in which generates additional hash level -$ldap = $ldap->{ldapserver} or die ldapserver_error('id="ldapserver"'); +if ( exists $ldap->{ldapserver} ) { + $ldap = $ldap->{ldapserver} or die ldapserver_error('id="ldapserver"'); +} my $prefhost = $ldap->{hostname} or die ldapserver_error('hostname'); my $base = $ldap->{base} or die ldapserver_error('base'); $ldapname = $ldap->{user} ; -- 2.39.5