From b732dcaeb35650b6d99d49c9cdc88201a90c18bd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 19 Sep 2013 11:11:44 +0200 Subject: [PATCH] Only set the cached instance if driver is valid As I could see at other locations in the code, the ldap driver instance can be invalid. And if the instance is invalid, the getStaticLdap() function gets called again. Caching would prevent the function from retrying to initiate the ldapDrivers object. This commit adds conditional caching: only if the ldap driver instance is valid, the object gets cached. This ensures that a retry with this function would really try to create a new ldapDrivers object and not simply return the (invalid) cached one. --- inc/drivers_ldap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/drivers_ldap.php b/inc/drivers_ldap.php index a6f7211f..1c080467 100644 --- a/inc/drivers_ldap.php +++ b/inc/drivers_ldap.php @@ -254,7 +254,10 @@ function getStaticLdap() { // If the instance is not there, create one if(!isset($instance)) { $ldapDrivers = new ldapDrivers($c->authenticate_hook['config']); - $instance = $ldapDrivers + + if ($ldapDrivers->valid) { + $instance = $ldapDrivers + } } else { $ldapDrivers = $instance