From fb2fe616b566d037aff5bcea373ba860f0d00fc8 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 22 May 2014 11:21:29 +0000 Subject: [PATCH] fix implementation of calling (set|get|unset)Cache with install_id to behave identical to call to (set|get|unset)Instance for current instances install_id (install_id was used directly in keys) --- phpgwapi/inc/class.egw_cache.inc.php | 31 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/phpgwapi/inc/class.egw_cache.inc.php b/phpgwapi/inc/class.egw_cache.inc.php index 7cbe241cf9..a70ffc4948 100644 --- a/phpgwapi/inc/class.egw_cache.inc.php +++ b/phpgwapi/inc/class.egw_cache.inc.php @@ -589,17 +589,21 @@ class egw_cache /** * Generate a new instance key and by doing so effectivly flushes whole instance cache * + * @param string $install_id=null default use install_id of current instance * @return string new key also stored in self::$instance_key */ - static public function generate_instance_key() + static public function generate_instance_key($install_id=null) { - $install_id = self::get_system_config('install_id'); + if (!isset($install_id)) + { + self::$instance_key = null; + $install_id = self::get_system_config('install_id'); + } + $instance_key = self::INSTANCE.'-'.$install_id.'-'.microtime(true); + self::setTree(__CLASS__, $install_id, $instance_key); - self::$instance_key = self::INSTANCE.'-'.$install_id.'-'.microtime(true); - self::setTree(__CLASS__, $install_id, self::$instance_key); - - //error_log(__METHOD__."() install_id='$install_id' returning '".self::$instance_key."'"); - return self::$instance_key; + //error_log(__METHOD__."(install_id='$install_id') returning '".$instance_key."'"); + return $instance_key; } /** @@ -628,18 +632,23 @@ class egw_cache } $level_key = $tree_key; break; + default: // arbitrary install_id given --> check for current instance + if ($level !== $GLOBALS['egw_info']['server']['install_id']) + { + $level_key = self::getTree(__CLASS__, $level); + if (!isset($level_key)) $level_key = self::generate_instance_key($level); + break; + } + // fall-through for current instance 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(); + if (!isset(self::$instance_key)) self::$instance_key = self::generate_instance_key(); } $level_key = self::$instance_key; break; - default: - $level_key = $level; - break; } return array($level_key, $app, $location); }