From 11aeba3b6864a4cc7720a9e3c9e299ebc7e5f84b 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. --- 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 face1e428f3..c87ea20c935 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.20.1