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:16:24 +00:00
parent 6d39bb4802
commit 9f8a77283c
3 changed files with 31 additions and 12 deletions

View File

@ -191,6 +191,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']))
@ -217,8 +224,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
@ -233,8 +239,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
@ -272,6 +276,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)

View File

@ -316,6 +316,13 @@ class egw_vfs extends vfs_stream_wrapper
{
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

@ -168,6 +168,13 @@ class vfs_stream_wrapper implements iface_stream_wrapper
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
*
@ -179,15 +186,13 @@ class vfs_stream_wrapper implements iface_stream_wrapper
*/
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)
@ -235,7 +240,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper
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;
}
@ -1120,9 +1125,9 @@ class vfs_stream_wrapper implements iface_stream_wrapper
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();
}
/**