fixed a couple more issues with session reusage when using sharing urls:

- to resolve sharing-path to url, we need to restore full mount-tab
- egw_vfs::clearstatcache() was not clearing resolve_url cache, causing previous share to be used
- need to set egw_info[user][vfs_user] after egw_session::create, as it overwrites it
This commit is contained in:
Ralf Becker 2015-03-02 21:09:08 +00:00
parent fb295089a6
commit 157cfd84f8
3 changed files with 31 additions and 12 deletions

View File

@ -336,6 +336,13 @@ class Vfs extends Vfs\StreamWrapper
{
self::$fstab = $api_config['vfs_fstab'];
}
else
{
self::$fstab = array(
'/' => 'sqlfs://$host/',
'/apps' => 'links://$host/apps',
);
}
unset($api_config);
}
if (is_null($url) || is_null($path))

View File

@ -176,6 +176,13 @@ class StreamWrapper implements StreamWrapperIface
return $url;
}
/**
* Cache of already resolved urls
*
* @var array with path => target
*/
private static $resolve_url_cache = array();
/**
* Resolve the given path according to our fstab
*
@ -187,15 +194,13 @@ class StreamWrapper implements StreamWrapperIface
*/
static function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true)
{
static $cache = array();
$path = self::get_path($_path);
// we do some caching here
if (isset($cache[$path]) && $replace_user_pass_host)
if (isset(self::$resolve_url_cache[$path]) && $replace_user_pass_host)
{
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '{$cache[$path]}' (from cache)");
return $cache[$path];
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)");
return self::$resolve_url_cache[$path];
}
// check if we can already resolve path (or a part of it) with a known symlinks
if ($use_symlinkcache)
@ -243,7 +248,7 @@ class StreamWrapper implements StreamWrapperIface
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$url'");
if ($replace_user_pass_host) $cache[$path] = $url;
if ($replace_user_pass_host) self::$resolve_url_cache[$path] = $url;
return $url;
}
@ -1128,9 +1133,9 @@ class StreamWrapper implements StreamWrapperIface
static function clearstatcache($path='/')
{
//error_log(__METHOD__."('$path')");
self::$symlink_cache = array();
self::$symlink_cache = self::$resolve_url_cache = array();
self::_call_on_backend('clearstatcache', array($path), true, 0);
self::$symlink_cache = array();
self::$symlink_cache = self::$resolve_url_cache = array();
}
/**

View File

@ -197,6 +197,13 @@ class egw_sharing
common::egw_exit();
}
// need to reset fs_tab, as resolve_url does NOT work with just share mounted
if (count($GLOBALS['egw_info']['server']['vfs_fstab']) <= 1)
{
unset($GLOBALS['egw_info']['server']['vfs_fstab']); // triggers reset of fstab in mount()
$GLOBALS['egw_info']['server']['vfs_fstab'] = egw_vfs::mount();
egw_vfs::clearstatcache();
}
$share['resolve_url'] = egw_vfs::resolve_url($share['share_path']);
// if share not writable append ro=1 to mount url to make it readonly
if (!self::$db->from_bool($share['share_writable']))
@ -223,8 +230,7 @@ class egw_sharing
);
$share['share_root'] = '/';
// need to store new fstab and vfs_user in session to allow GET requests / downloads via WebDAV
$GLOBALS['egw_info']['user']['vfs_user'] = egw_vfs::$user = $share['share_owner'];
egw_vfs::$user = $share['share_owner'];
}
// mounting share
@ -239,8 +245,6 @@ class egw_sharing
common::egw_exit();
}
egw_vfs::$is_root = false;
$GLOBALS['egw_info']['server']['vfs_fstab'] = egw_vfs::mount();
egw_vfs::clearstatcache();
// update accessed timestamp
@ -278,6 +282,9 @@ class egw_sharing
{
$GLOBALS['egw']->session->commit_session();
}
// need to store new fstab and vfs_user in session to allow GET requests / downloads via WebDAV
$GLOBALS['egw_info']['user']['vfs_user'] = egw_vfs::$user;
$GLOBALS['egw_info']['server']['vfs_fstab'] = egw_vfs::mount();
// update modified egw and egw_info again in session, if neccessary
if ($keep_session || $sessionid)