fixed infinit recursion on deleting entries with linked files, first reported by Peter Goerzen

This commit is contained in:
Ralf Becker 2008-04-21 16:55:52 +00:00
parent 72cbfd4083
commit 9e838a4068
2 changed files with 17 additions and 3 deletions

View File

@ -760,14 +760,14 @@ class egw_link extends solink
}
/**
* deletes an attached file
* deletes a single or all attached files of an entry (for all there's no acl check, as the entry probably not exists any more!)
*
* @param int/string $app > 0: file_id of an attchemnt or $app/$id entry which linked to
* @param string $id='' id in app
* @param string $fname filename
* @param string $fname='' filename
* @return boolean/array false on error ($app or $id not found), array with path as key and boolean result of delete
*/
static function delete_attached($app,$id='',$fname = '')
static function delete_attached($app,$id='',$fname='')
{
if ((int)$app > 0) // is file_id
{
@ -780,6 +780,12 @@ class egw_link extends solink
return False; // dont delete more than all attachments of an entry
}
$url = self::vfs_path($app,$id,$fname);
if (!$fname || !$id) // we delete the whole entry (or all entries), which probably not exist anymore
{
$current_is_root = egw_vfs::$is_root;
egw_vfs::$is_root = true;
}
}
if (self::DEBUG)
{
@ -790,6 +796,10 @@ class egw_link extends solink
// try removing the dir, in case it's empty
@rmdir(egw_vfs::dirname($url));
}
if (!is_null($current_is_root))
{
egw_vfs::$is_root = $current_is_root;
}
return $Ok;
}

View File

@ -58,6 +58,10 @@ class links_stream_wrapper extends sqlfs_stream_wrapper
*/
static function check_extended_acl($url,$check)
{
if (egw_vfs::$is_root)
{
return true;
}
$path = parse_url($url,PHP_URL_PATH);
list(,$apps,$app,$id,$rel_path) = explode('/',$path,5);