protected $_cache;
/**
+ * Incrementing version number if cached classes change.
+ *
+ * @var integer
+ */
+ private $_cacheVersion = 2;
+
+ /**
* Cache for getPermission().
*
* @var array
return $this->_permsCache[$name];
}
- $perm = $this->_cache->get('perm_' . $name, $GLOBALS['conf']['cache']['default_lifetime']);
+ $perm = $this->_cache->get('perm_' . $this->_cacheVersion . $name, $GLOBALS['conf']['cache']['default_lifetime']);
if ($perm === false) {
$perm = $this->_datatree->getObject($name, 'Horde_Perms_Permission_DataTreeObject');
- $this->_cache->set('perm_' . $name, serialize($perm), $GLOBALS['conf']['cache']['default_lifetime']);
+ $this->_cache->set('perm_' . $this->_cacheVersion . $name, serialize($perm), $GLOBALS['conf']['cache']['default_lifetime']);
$this->_permsCache[$name] = $perm;
} else {
$this->_permsCache[$name] = unserialize($perm);
if (empty($name)) {
throw Horde_Perms_Exception('Permission names must be non-empty.');
}
- $this->_cache->expire('perm_' . $name);
- $this->_cache->expire('perm_exists_' . $name);
+ $this->_cache->expire('perm_' . $this->_cacheVersion . $name);
+ $this->_cache->expire('perm_exists_' . $this->_cacheVersion . $name);
return $this->_datatree->add($perm);
}
$keys = $this->_datatree->get(DATATREE_FORMAT_FLAT, $perm->name, true);
foreach ($keys as $key) {
- $this->_cache->expire('perm_' . $key);
- $this->_cache->expire('perm_exists_' . $key);
+ $this->_cache->expire('perm_' . $this->_cacheVersion . $key);
+ $this->_cache->expire('perm_exists_' . $this->_cacheVersion . $key);
}
return $this->_datatree->remove($perm->name, $force);
*/
public function exists($permission)
{
- $key = 'perm_exists_' . $permission;
+ $key = 'perm_exists_' . $this->_cacheVersion . $permission;
$exists = $this->_cache->get($key, $GLOBALS['conf']['cache']['default_lifetime']);
if ($exists === false) {
$exists = $this->_datatree->exists($permission);
protected $_cache;
/**
+ * Incrementing version number if cached classes change.
+ *
+ * @var integer
+ */
+ private $_cacheVersion = 2;
+
+ /**
* Cache of previously retrieved permissions.
*
* @var array
$this->_connect();
- $perm = $this->_cache->get('perm_sql' . $name, $GLOBALS['conf']['cache']['default_lifetime']);
+ $perm = $this->_cache->get('perm_sql' . $this->_cacheVersion . $name, $GLOBALS['conf']['cache']['default_lifetime']);
if (empty($perm)) {
$query = 'SELECT perm_id, perm_data FROM horde_perms WHERE perm_name = ?';
$result = $this->_db->getRow($query, array($name), DB_FETCHMODE_ASSOC);
$object->setId($result['perm_id']);
$object->setData(unserialize($result['perm_data']));
- $this->_cache->set('perm_sql' . $name, serialize($object));
+ $this->_cache->set('perm_sql' . $this->_cacheVersion . $name, serialize($object));
$this->_permsCache[$name] = $object;
} else {
throw new Horde_Perms_Exception('Permission name must be non-empty.');
}
- $this->_cache->expire('perm_sql' . $name);
- $this->_cache->expire('perm_sql_exists_' . $name);
+ $this->_cache->expire('perm_sql' . $this->_cacheVersion . $name);
+ $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $name);
$this->_connect();
$id = $this->_write_db->nextId('horde_perms');
}
$name = $perm->getName();
- $this->_cache->expire('perm_sql' . $name);
- $this->_cache->expire('perm_sql_exists_' . $name);
+ $this->_cache->expire('perm_sql' . $this->_cacheVersion . $name);
+ $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $name);
$this->_connect();
$query = 'DELETE FROM horde_perms WHERE perm_name = ?';
*/
public function exists($permission)
{
- $key = 'perm_sql_exists_' . $permission;
+ $key = 'perm_sql_exists_' . $this->_cacheVersion . $permission;
$exists = $this->_cache->get($key, $GLOBALS['conf']['cache']['default_lifetime']);
if ($exists === false) {
$this->_connect();