diff --git a/phpgwapi/inc/class.accounts_ads.inc.php b/phpgwapi/inc/class.accounts_ads.inc.php index 89bd1212a8..9f399f74ff 100644 --- a/phpgwapi/inc/class.accounts_ads.inc.php +++ b/phpgwapi/inc/class.accounts_ads.inc.php @@ -139,12 +139,12 @@ class accounts_ads if (empty($config['ads_host'])) throw new Exception("Required ADS host name(s) missing!"); if (empty($config['ads_domain'])) throw new Exception("Required ADS domain missing!"); - $base_dn = array(); + $base_dn_parts = array(); foreach(explode('.', $config['ads_domain']) as $dc) { - $base_dn[] = 'DC='.$dc; + $base_dn_parts[] = 'DC='.$dc; } - $base_dn = implode(',', $base_dn); + $base_dn = implode(',', $base_dn_parts); $options = array( 'domain_controllers' => preg_split('/[ ,]+/', $config['ads_host']), 'base_dn' => $base_dn ? $base_dn : null, @@ -170,10 +170,10 @@ class accounts_ads */ protected function get_sid($account_id=null) { - static $domain_sid; + static $domain_sid = null; if (!isset($domain_sid)) { - $domain_sid = egw_cache::getInstance(__CLASS__, 'ads_domain_sid'); + $domain_sid = egw_cache::getCache($this->frontend->config['install_id'], __CLASS__, 'ads_domain_sid'); if ((!is_array($domain_sid) || !isset($domain_sid[$this->frontend->config['ads_domain']])) && ($adldap = self::get_adldap($this->frontend->config)) && ($sr = ldap_search($adldap->getLdapConnection(), $adldap->getBaseDn(), '(objectclass=domain)', array('objectsid'))) && @@ -181,7 +181,7 @@ class accounts_ads { $domain_sid = array(); $domain_sid[$this->frontend->config['ads_domain']] = $adldap->utilities()->getTextSID($entries[0]['objectsid'][0]); - egw_cache::setInstance(__CLASS__, 'ads_domain_sid', $domain_sid); + egw_cache::setCache($this->frontend->config['install_id'], __CLASS__, 'ads_domain_sid', $domain_sid); } } $sid = $domain_sid[$this->frontend->config['ads_domain']]; @@ -231,6 +231,7 @@ class accounts_ads { $context = $this->ads_context(true); $base = $this->adldap->getBaseDn(); + $matches = null; if (!preg_match('/^(.*),'.preg_quote($base, '/').'$/i', $context, $matches)) { throw new egw_exception_wrong_userinput("Wrong or not configured ADS context '$context' (baseDN='$base')!"); @@ -556,7 +557,7 @@ class accounts_ads */ protected static function _when2ts($when) { - static $utc; + static $utc=null; if (!isset($utc)) $utc = new DateTimeZone('UTC'); list($when) = explode('.', $when); // remove .0Z not understood by createFromFormat @@ -1101,6 +1102,7 @@ class accounts_ads { foreach($this->filter(array($to_ldap[$which] => $name), $account_type) as $account_id => $account_lid) { + unset($account_lid); $ret = $account_id; break; } @@ -1132,6 +1134,8 @@ class accounts_ads */ function update_lastlogin($_account_id, $ip) { + unset($_account_id, $ip); // not used, but required by function signature + return false; // not longer supported } diff --git a/phpgwapi/inc/class.egw_cache.inc.php b/phpgwapi/inc/class.egw_cache.inc.php index bed9f12441..26f72d0354 100644 --- a/phpgwapi/inc/class.egw_cache.inc.php +++ b/phpgwapi/inc/class.egw_cache.inc.php @@ -7,7 +7,7 @@ * @package api * @subpackage cache * @author Ralf Becker - * @copyright (c) 2009-13 by Ralf Becker + * @copyright (c) 2009-14 by Ralf Becker * @version $Id$ */ @@ -45,6 +45,9 @@ * resonable expiry times or think about an other means of clearing that particular item. * (Not clearing of tree-level cache is important, as regenerating it is an expensive * operation for a huge scale EGroupware hosting operation.) + * + * Apps needing to talk to multiple EGroupware instances (eg. Stylite Managementserver) + * can use install_id of instance as $level parameter to (set|get|unset)Cache method. */ class egw_cache { @@ -107,6 +110,7 @@ class egw_cache case self::INSTANCE: case self::TREE: + default: if (!($provider = self::get_provider($level))) { return false; @@ -147,6 +151,7 @@ class egw_cache case self::INSTANCE: case self::TREE: + default: if (!($provider = self::get_provider($level))) { return null; @@ -214,6 +219,7 @@ class egw_cache case self::INSTANCE: case self::TREE: + default: if (!($provider = self::get_provider($level, false))) { return false; @@ -445,7 +451,7 @@ class egw_cache * * The returned provider already has an opened connection * - * @param string $level egw_cache::(TREE|INSTANCE) + * @param string $level egw_cache::(TREE|INSTANCE) or install_id * @param boolean $log_not_found=true false do not log if no provider found, used eg. to supress error via unsetCache during installation * @return egw_cache_provider */ @@ -453,6 +459,8 @@ class egw_cache { static $providers = array(); + if ($level != self::TREE) $level = self::INSTANCE; + if (!isset($providers[$level])) { $params = $GLOBALS['egw_info']['server']['cache_provider_'.strtolower($level)]; @@ -615,39 +623,43 @@ class egw_cache /** * Get keys array from $level, $app and $location * - * @param string $level egw_cache::(TREE|INSTANCE) + * @param string $level egw_cache::(TREE|INSTANCE) or instance_id * @param string $app * @param string $location * @return array */ static public function keys($level,$app,$location) { - static $bases = array(); + static $tree_key = null; - if (!isset($bases[$level]) || $level == self::INSTANCE && $bases[$level] != self::$instance_key) + switch($level) { - switch($level) - { - case self::TREE: - $bases[$level] = $level.'-'.str_replace(array(':','/','\\'),'-',EGW_SERVER_ROOT); + case self::TREE: + if (!isset($tree_key)) + { + $tree_key = $level.'-'.str_replace(array(':','/','\\'),'-',EGW_SERVER_ROOT); // add charset to key, if not utf-8 (as everything we store depends on charset!) if (($charset = self::get_system_config('system_charset',false)) && $charset != 'utf-8') { - $bases[$level] .= '-'.$charset; + $tree_key .= '-'.$charset; } - break; - case self::INSTANCE: - if (!isset(self::$instance_key)) - { - self::$instance_key = self::getTree(__CLASS__, self::get_system_config('install_id')); - //error_log(__METHOD__."('$level',...) instance_key read from tree-cache=".array2string(self::$instance_key)); - if (!isset(self::$instance_key)) self::generate_instance_key(); - } - $bases[$level] = self::$instance_key; - break; - } + } + $level_key = $tree_key; + break; + case self::INSTANCE: + if (!isset(self::$instance_key)) + { + self::$instance_key = self::getTree(__CLASS__, self::get_system_config('install_id')); + //error_log(__METHOD__."('$level',...) instance_key read from tree-cache=".array2string(self::$instance_key)); + if (!isset(self::$instance_key)) self::generate_instance_key(); + } + $level_key = self::$instance_key; + break; + default: + $level_key = $level; + break; } - return array($bases[$level],$app,$location); + return array($level_key, $app, $location); } /**