mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
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:
parent
fb295089a6
commit
157cfd84f8
@ -336,6 +336,13 @@ class Vfs extends Vfs\StreamWrapper
|
|||||||
{
|
{
|
||||||
self::$fstab = $api_config['vfs_fstab'];
|
self::$fstab = $api_config['vfs_fstab'];
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self::$fstab = array(
|
||||||
|
'/' => 'sqlfs://$host/',
|
||||||
|
'/apps' => 'links://$host/apps',
|
||||||
|
);
|
||||||
|
}
|
||||||
unset($api_config);
|
unset($api_config);
|
||||||
}
|
}
|
||||||
if (is_null($url) || is_null($path))
|
if (is_null($url) || is_null($path))
|
||||||
|
@ -176,6 +176,13 @@ class StreamWrapper implements StreamWrapperIface
|
|||||||
return $url;
|
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
|
* 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 function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true)
|
||||||
{
|
{
|
||||||
static $cache = array();
|
|
||||||
|
|
||||||
$path = self::get_path($_path);
|
$path = self::get_path($_path);
|
||||||
|
|
||||||
// we do some caching here
|
// 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)");
|
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '".self::$resolve_url_cache[$path]."' (from cache)");
|
||||||
return $cache[$path];
|
return self::$resolve_url_cache[$path];
|
||||||
}
|
}
|
||||||
// check if we can already resolve path (or a part of it) with a known symlinks
|
// check if we can already resolve path (or a part of it) with a known symlinks
|
||||||
if ($use_symlinkcache)
|
if ($use_symlinkcache)
|
||||||
@ -243,7 +248,7 @@ class StreamWrapper implements StreamWrapperIface
|
|||||||
|
|
||||||
if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$path') = '$url'");
|
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;
|
return $url;
|
||||||
}
|
}
|
||||||
@ -1128,9 +1133,9 @@ class StreamWrapper implements StreamWrapperIface
|
|||||||
static function clearstatcache($path='/')
|
static function clearstatcache($path='/')
|
||||||
{
|
{
|
||||||
//error_log(__METHOD__."('$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::_call_on_backend('clearstatcache', array($path), true, 0);
|
||||||
self::$symlink_cache = array();
|
self::$symlink_cache = self::$resolve_url_cache = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,6 +197,13 @@ class egw_sharing
|
|||||||
common::egw_exit();
|
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']);
|
$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 share not writable append ro=1 to mount url to make it readonly
|
||||||
if (!self::$db->from_bool($share['share_writable']))
|
if (!self::$db->from_bool($share['share_writable']))
|
||||||
@ -223,8 +230,7 @@ class egw_sharing
|
|||||||
);
|
);
|
||||||
|
|
||||||
$share['share_root'] = '/';
|
$share['share_root'] = '/';
|
||||||
// need to store new fstab and vfs_user in session to allow GET requests / downloads via WebDAV
|
egw_vfs::$user = $share['share_owner'];
|
||||||
$GLOBALS['egw_info']['user']['vfs_user'] = egw_vfs::$user = $share['share_owner'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mounting share
|
// mounting share
|
||||||
@ -239,8 +245,6 @@ class egw_sharing
|
|||||||
common::egw_exit();
|
common::egw_exit();
|
||||||
}
|
}
|
||||||
egw_vfs::$is_root = false;
|
egw_vfs::$is_root = false;
|
||||||
|
|
||||||
$GLOBALS['egw_info']['server']['vfs_fstab'] = egw_vfs::mount();
|
|
||||||
egw_vfs::clearstatcache();
|
egw_vfs::clearstatcache();
|
||||||
|
|
||||||
// update accessed timestamp
|
// update accessed timestamp
|
||||||
@ -278,6 +282,9 @@ class egw_sharing
|
|||||||
{
|
{
|
||||||
$GLOBALS['egw']->session->commit_session();
|
$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
|
// update modified egw and egw_info again in session, if neccessary
|
||||||
if ($keep_session || $sessionid)
|
if ($keep_session || $sessionid)
|
||||||
|
Loading…
Reference in New Issue
Block a user