From 97ee29eb377b573d7ea86ee844012aa5ca212ec6 Mon Sep 17 00:00:00 2001 From: Miguel Pereira Date: Mon, 19 Nov 2018 10:55:56 +0100 Subject: [PATCH] Update login-ldap.php In some rare occasions, the ldap setup can return null when reading the $attributes[$group_indentifier]. By checking that it isn't empty before shifting the array, we prevent the following error: * array_shift expected parameter to be array, null given --- login-ldap.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/login-ldap.php b/login-ldap.php index 6578bf3..4ea70e4 100644 --- a/login-ldap.php +++ b/login-ldap.php @@ -181,11 +181,16 @@ class LoginLDAPPlugin extends Plugin foreach ($groups as $group) { $attributes = $group->getAttributes(); - $user_group = array_shift($attributes[$group_indentifier]); - $user_groups[] = $user_group; + + // make sure we have an array to read + if ( !empty($attributes) && !empty($attributes[$group_indentifier]) && is_array($attributes[$group_indentifier]) ) + { + $user_group = array_shift($attributes[$group_indentifier]); + $user_groups[] = $user_group; - if ($this->config->get('plugins.login-ldap.store_ldap_data', false)) { - $userdata['ldap']['groups'][] = $user_group; + if ($this->config->get('plugins.login-ldap.store_ldap_data', false)) { + $userdata['ldap']['groups'][] = $user_group; + } } } }