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 <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-05-25 10:34:49 +02:00
parent e10b25d594
commit 8b4f2db7ef
1 changed files with 3 additions and 1 deletions

View File

@ -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 <ldapserver id="ldapserver"> 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} ;