]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
You cannot use static that way - using another approach to save reuse the default...
authorCraig Andrews <candrews@integralblue.com>
Wed, 18 Nov 2009 21:58:06 +0000 (16:58 -0500)
committerCraig Andrews <candrews@integralblue.com>
Wed, 18 Nov 2009 21:58:06 +0000 (16:58 -0500)
plugins/LdapAuthentication/LdapAuthenticationPlugin.php
plugins/LdapAuthorization/LdapAuthorizationPlugin.php

index 9e089485c6e55da3552edb3108ee5e6959fcf5fd..8caacff46433ec3d3a7af40574df9ea403ec431b 100644 (file)
@@ -159,24 +159,21 @@ class LdapAuthenticationPlugin extends AuthenticationPlugin
     }
     
     function ldap_get_connection($config = null){
-        if($config == null){
-            static $ldap = null;
-            if($ldap != null){
-                return $ldap;
-            }
-            $config = $this->ldap_get_config();
+        if($config == null && isset($this->default_ldap)){
+            return $this->default_ldap;
         }
         
         //cannot use Net_LDAP2::connect() as StatusNet uses
         //PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
         //PEAR handling can be overridden on instance objects, so we do that.
-        $ldap = new Net_LDAP2($config);
+        $ldap = new Net_LDAP2(isset($config)?$config:$this->ldap_get_config());
         $ldap->setErrorHandling(PEAR_ERROR_RETURN);
         $err=$ldap->bind();
         if (Net_LDAP2::isError($err)) {
             common_log(LOG_WARNING, 'Could not connect to LDAP server: '.$err->getMessage());
             return false;
         }
+        if($config == null) $this->default_ldap=$ldap;
         return $ldap;
     }
     
index 91a343f4087ae0dfd5c8f953c70042a6428e4be2..5e759c3793045939857044d8ed5c5bff29a08855 100644 (file)
@@ -158,24 +158,21 @@ class LdapAuthorizationPlugin extends AuthorizationPlugin
 
     //-----the below function were copied from LDAPAuthenticationPlugin. They will be moved to a utility class soon.----\\
     function ldap_get_connection($config = null){
-        if($config == null){
-            static $ldap = null;
-            if($ldap != null){
-                return $ldap;
-            }
-            $config = $this->ldap_get_config();
+        if($config == null && isset($this->default_ldap)){
+            return $this->default_ldap;
         }
         
         //cannot use Net_LDAP2::connect() as StatusNet uses
         //PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'handleError');
         //PEAR handling can be overridden on instance objects, so we do that.
-        $ldap = new Net_LDAP2($config);
+        $ldap = new Net_LDAP2(isset($config)?$config:$this->ldap_get_config());
         $ldap->setErrorHandling(PEAR_ERROR_RETURN);
         $err=$ldap->bind();
         if (Net_LDAP2::isError($err)) {
             common_log(LOG_WARNING, 'Could not connect to LDAP server: '.$err->getMessage());
             return false;
         }
+        if($config == null) $this->default_ldap=$ldap;
         return $ldap;
     }