diff --git a/api/src/Vfs.php b/api/src/Vfs.php index e6fc809399..eb22205d01 100644 --- a/api/src/Vfs.php +++ b/api/src/Vfs.php @@ -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)) diff --git a/api/src/Vfs/StreamWrapper.php b/api/src/Vfs/StreamWrapper.php index 53995e7b30..bb9167ae70 100644 --- a/api/src/Vfs/StreamWrapper.php +++ b/api/src/Vfs/StreamWrapper.php @@ -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(); } /** diff --git a/phpgwapi/inc/class.egw_sharing.inc.php b/phpgwapi/inc/class.egw_sharing.inc.php index 278ea4178d..b944cd7538 100644 --- a/phpgwapi/inc/class.egw_sharing.inc.php +++ b/phpgwapi/inc/class.egw_sharing.inc.php @@ -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)