mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
* EPL/Filemanager: fix PHP Fatal using file-a-file dialog (upload with setting eg. a comment)
This commit is contained in:
parent
57e6d5b205
commit
a72db03fdb
@ -142,30 +142,32 @@ class Vfs
|
||||
*
|
||||
* @param string $path filename with absolute path in the eGW VFS
|
||||
* @param string $mode 'r', 'w', ... like fopen
|
||||
* @param resource $context =null context to pass to stream-wrapper
|
||||
* @return resource
|
||||
*/
|
||||
static function fopen($path,$mode)
|
||||
static function fopen($path, $mode, $context=null)
|
||||
{
|
||||
if ($path[0] != '/')
|
||||
{
|
||||
throw new Exception\AssertionFailed("Filename '$path' is not an absolute path!");
|
||||
}
|
||||
return fopen(self::PREFIX.$path,$mode);
|
||||
return $context ? fopen(self::PREFIX.$path, $mode, false, $context) : fopen(self::PREFIX.$path, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* opendir working on just the eGW VFS: returns resource for readdir() etc.
|
||||
*
|
||||
* @param string $path filename with absolute path in the eGW VFS
|
||||
* @param resource $context =null context to pass to stream-wrapper
|
||||
* @return resource
|
||||
*/
|
||||
static function opendir($path)
|
||||
static function opendir($path, $context=null)
|
||||
{
|
||||
if ($path[0] != '/')
|
||||
{
|
||||
throw new Exception\AssertionFailed("Directory '$path' is not an absolute path!");
|
||||
}
|
||||
return opendir(self::PREFIX.$path);
|
||||
return $context ? opendir(self::PREFIX.$path, $context) : opendir(self::PREFIX.$path);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2111,13 +2113,16 @@ class Vfs
|
||||
if (!self::stat($target))
|
||||
{
|
||||
self::touch($target); // create empty file, to be able to attach properties
|
||||
self::$treat_as_new = true; // notify as new
|
||||
// tell vfs stream-wrapper to treat file in following copy as a new file notification-wises
|
||||
$context = stream_context_create(array(
|
||||
self::SCHEME => array('treat_as_new' => true)
|
||||
));
|
||||
}
|
||||
self::proppatch($target, $props);
|
||||
}
|
||||
if (is_resource($tmp_name))
|
||||
{
|
||||
$ret = ($dest = self::fopen($target, 'w')) &&
|
||||
$ret = ($dest = self::fopen($target, 'w', $context)) &&
|
||||
stream_copy_to_stream($tmp_name, $dest) !== false &&
|
||||
fclose($dest) ? self::stat($target) : false;
|
||||
|
||||
@ -2125,7 +2130,9 @@ class Vfs
|
||||
}
|
||||
else
|
||||
{
|
||||
$ret = copy($tmp_name,self::PREFIX.$target) ? self::stat($target) : false;
|
||||
$ret = ($context ? copy($tmp_name, self::PREFIX.$target, $context) :
|
||||
copy($tmp_name, self::PREFIX.$target)) ?
|
||||
self::stat($target) : false;
|
||||
}
|
||||
if (self::LOG_LEVEL > 1 || !$ret && self::LOG_LEVEL) error_log(__METHOD__."($tmp_name, $target, ".array2string($props).") returning ".array2string($ret));
|
||||
return $ret;
|
||||
|
@ -900,7 +900,7 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (is_null($time))
|
||||
if (!$time)
|
||||
{
|
||||
return true; // new (empty) file created with current mod time
|
||||
}
|
||||
|
@ -291,13 +291,6 @@ class StreamWrapper implements StreamWrapperIface
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used from egw_vfs to tell vfs notifications to treat an opened file as a new file
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
static protected $treat_as_new;
|
||||
|
||||
/**
|
||||
* This method is called immediately after your stream object is created.
|
||||
*
|
||||
@ -335,11 +328,12 @@ class StreamWrapper implements StreamWrapperIface
|
||||
$this->opened_stream_is_new = !$stat;
|
||||
|
||||
// are we requested to treat the opened file as new file (only for files opened NOT for reading)
|
||||
if ($mode[0] != 'r' && !$this->opened_stream_is_new && self::$treat_as_new)
|
||||
if ($mode[0] != 'r' && !$this->opened_stream_is_new && $this->context &&
|
||||
($opts = stream_context_get_params($this->context)) &&
|
||||
$opts['options'][self::SCHEME]['treat_as_new'])
|
||||
{
|
||||
$this->opened_stream_is_new = true;
|
||||
//error_log(__METHOD__."($path,$mode,...) stat=$stat, treat_as_new=".self::$treat_as_new." --> ".array2string($this->opened_stream_is_new));
|
||||
self::$treat_as_new = null;
|
||||
//error_log(__METHOD__."($path,$mode,...) stat=$stat, context=".array2string($opts)." --> ".array2string($this->opened_stream_is_new));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -494,7 +488,7 @@ class StreamWrapper implements StreamWrapperIface
|
||||
*/
|
||||
function stream_metadata($path, $option, $value)
|
||||
{
|
||||
if (!($url = $this->resolve_url_symlinks($path, $option == STREAM_META_TOUCH, false))) // true,false file need to exist, but do not resolve last component
|
||||
if (!($url = $this->resolve_url_symlinks($path, $option != STREAM_META_TOUCH, false))) // true,false file need to exist, but do not resolve last component
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user