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.
This commit is contained in:
Matthias Beyer 2013-09-19 11:11:44 +02:00 committed by Andrew McMillan
parent 40c87435c1
commit b732dcaeb3

View File

@ -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