Fixed SQL error now giving an exception: it's caused by

vfs_stream_wrapper::get_path() returning an url without path
(sqlfs://default <-- no trailing slash), which causes
sqlfs_stream_wrapper::url_stat() to be called for an empty path, which
gives the sql error.
This commit is contained in:
Ralf Becker 2009-07-01 18:03:46 +00:00
parent 9a5c0f8d9c
commit 078edd98fd
2 changed files with 12 additions and 4 deletions

View File

@ -969,6 +969,10 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
{
$path = substr($path,0,-1);
}
if (empty($path))
{
return false; // is invalid and gives sql error
}
// check if we already have the info from the last dir_open call, as the old vfs reads it anyway from the db
if (self::$stat_cache && isset(self::$stat_cache[$path]) && (is_null($eacl_access) || self::$stat_cache[$path] !== false))
{

View File

@ -1018,14 +1018,18 @@ class vfs_stream_wrapper implements iface_stream_wrapper
*/
static protected function get_path($path,$only_remove_scheme=self::SCHEME)
{
if ($path[0] != '/' && (!$only_remove_scheme || parse_url($path,PHP_URL_SCHEME) == $only_remove_scheme))
$url_parts = parse_url($path);
if ($path[0] != '/' && (!$only_remove_scheme || $url_parts['scheme'] == $only_remove_scheme))
{
$path = parse_url($path,PHP_URL_PATH);
$path = $url_parts['path'];
}
// remove trailing slashes eg. added by WebDAV
while (substr($path,-1) == '/' && $path != '/')
if ($url_parts['path'] != '/')
{
$path = substr($path,0,-1);
while (substr($path,-1) == '/' && $path != '/')
{
$path = substr($path,0,-1);
}
}
return $path;
}