From 4b58e870802fa809ab69c197ff86ebbe71fdf5eb Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 22 Jul 2016 18:22:15 +0200 Subject: [PATCH] fix not working symlinking vfs files to infologs/links, fixed multiple PHP deprecated should not call non-static self::url_stat static --- api/src/Vfs.php | 2 +- api/src/Vfs/Filesystem/StreamWrapper.php | 12 ++++++------ api/src/Vfs/Links/StreamWrapper.php | 8 ++++---- api/src/Vfs/Sqlfs/StreamWrapper.php | 23 ++++++++++++----------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/api/src/Vfs.php b/api/src/Vfs.php index 37d28bbf79..545959b440 100644 --- a/api/src/Vfs.php +++ b/api/src/Vfs.php @@ -2184,7 +2184,7 @@ class Vfs */ static function resolve_url($_path,$do_symlink=true,$use_symlinkcache=true,$replace_user_pass_host=true,$fix_url_query=false) { - Vfs\StreamWrapper::resolve_url($_path, $do_symlink, $use_symlinkcache, $replace_user_pass_host, $fix_url_query); + return Vfs\StreamWrapper::resolve_url($_path, $do_symlink, $use_symlinkcache, $replace_user_pass_host, $fix_url_query); } /** diff --git a/api/src/Vfs/Filesystem/StreamWrapper.php b/api/src/Vfs/Filesystem/StreamWrapper.php index 0c22a70846..2068f52b78 100644 --- a/api/src/Vfs/Filesystem/StreamWrapper.php +++ b/api/src/Vfs/Filesystem/StreamWrapper.php @@ -131,12 +131,12 @@ class StreamWrapper implements Vfs\StreamWrapperIface $read_only = str_replace('b','',$mode) == 'r'; // check access rights, based on the eGW mount perms - if (!($stat = self::url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist + if (!($stat = $this->url_stat($url,0)) || $mode[0] == 'x') // file not found or file should NOT exist { if ($mode[0] == 'r' || // does $mode require the file to exist (r,r+) $mode[0] == 'x' || // or file should not exist, but does !($dir = Vfs::dirname($url)) || - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=self::url_stat($dir,0))) // or we are not allowed to create it + !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=$this->url_stat($dir,0))) // or we are not allowed to create it { if (self::LOG_LEVEL) error_log(__METHOD__."($url,$mode,$options) file does not exist or can not be created!"); if (!($options & STREAM_URL_STAT_QUIET)) @@ -294,7 +294,7 @@ class StreamWrapper implements Vfs\StreamWrapperIface */ function stream_stat ( ) { - return self::url_stat($this->opened_stream_url,0); + return $this->url_stat($this->opened_stream_url,0); } /** @@ -337,12 +337,12 @@ class StreamWrapper implements Vfs\StreamWrapperIface $to = Vfs::parse_url($url_to); // check access rights - if (!($from_stat = self::url_stat($url_from,0)) || !($dir = Vfs::dirname($url_from)) || !Vfs::check_access($dir,Vfs::WRITABLE)) + if (!($from_stat = $this->url_stat($url_from,0)) || !($dir = Vfs::dirname($url_from)) || !Vfs::check_access($dir,Vfs::WRITABLE)) { if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $from[path] permission denied!"); return false; // no permission or file does not exist } - if (!($to_dir = Vfs::dirname($url_to)) || !Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = self::url_stat($to_dir,0))) + if (!($to_dir = Vfs::dirname($url_to)) || !Vfs::check_access($to_dir,Vfs::WRITABLE,$to_dir_stat = $this->url_stat($to_dir,0))) { if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $to_dir permission denied!"); return false; // no permission or parent-dir does not exist @@ -354,7 +354,7 @@ class StreamWrapper implements Vfs\StreamWrapperIface } // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems // for our vfs too, we abort here with an error, like the filesystem one does - if (($to_stat = self::url_stat($to['path'],0)) && + if (($to_stat = $this->url_stat($to['path'],0)) && ($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE)) { $is_dir = $to_stat['mime'] === self::DIR_MIME_TYPE ? 'a' : 'no'; diff --git a/api/src/Vfs/Links/StreamWrapper.php b/api/src/Vfs/Links/StreamWrapper.php index e33d5595dd..3f50ee83f8 100644 --- a/api/src/Vfs/Links/StreamWrapper.php +++ b/api/src/Vfs/Links/StreamWrapper.php @@ -262,7 +262,7 @@ class StreamWrapper extends LinksParent /** * This method is called immediately after your stream object is created. * - * Reimplemented from sqlfs to ensure self::url_stat is called, to fill sqlfs stat cache with our eacl! + * Reimplemented from sqlfs to ensure $this->url_stat is called, to fill sqlfs stat cache with our eacl! * And to return vcard for url /apps/addressbook/$id/.entry * * @param string $url URL that was passed to fopen() and that this object is expected to retrieve @@ -277,7 +277,7 @@ class StreamWrapper extends LinksParent function stream_open ( $url, $mode, $options, &$opened_path ) { // the following call is necessary to fill sqlfs_stream_wrapper::$stat_cache, WITH the extendes ACL! - $stat = self::url_stat($url,0); + $stat = $this->url_stat($url,0); //error_log(__METHOD__."('$url', '$mode', $options) stat=".array2string($stat)); // return vCard as /.entry @@ -321,7 +321,7 @@ class StreamWrapper extends LinksParent */ function dir_opendir ( $url, $options ) { - if (!parent::url_stat($url, STREAM_URL_STAT_QUIET) && self::url_stat($url, STREAM_URL_STAT_QUIET)) + if (!parent::url_stat($url, STREAM_URL_STAT_QUIET) && $this->url_stat($url, STREAM_URL_STAT_QUIET)) { $this->opened_dir = array(); return true; @@ -340,7 +340,7 @@ class StreamWrapper extends LinksParent { if (self::LOG_LEVEL > 1) error_log(__METHOD__."($url,$time,$atime)"); - if (!($stat = self::url_stat($url,STREAM_URL_STAT_QUIET))) + if (!($stat = $this->url_stat($url,STREAM_URL_STAT_QUIET))) { // file does not exist --> create an empty one if (!($f = fopen(self::SCHEME.'://default'.Vfs::parse_url($url,PHP_URL_PATH),'w')) || !fclose($f)) diff --git a/api/src/Vfs/Sqlfs/StreamWrapper.php b/api/src/Vfs/Sqlfs/StreamWrapper.php index e53742da74..3e3ba79b08 100644 --- a/api/src/Vfs/Sqlfs/StreamWrapper.php +++ b/api/src/Vfs/Sqlfs/StreamWrapper.php @@ -201,11 +201,11 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface parse_str(parse_url($url, PHP_URL_QUERY), $this->dir_url_params); - if (!is_null($overwrite_new) || !($stat = static::url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x') // file not found or file should NOT exist + if (!is_null($overwrite_new) || !($stat = $this->url_stat($path,STREAM_URL_STAT_QUIET)) || $mode[0] == 'x') // file not found or file should NOT exist { if (!$dir || $mode[0] == 'r' || // does $mode require the file to exist (r,r+) $mode[0] == 'x' && $stat || // or file should not exist, but does - !($dir_stat=static::url_stat($dir,STREAM_URL_STAT_QUIET)) || // or parent dir does not exist create it + !($dir_stat=$this->url_stat($dir,STREAM_URL_STAT_QUIET)) || // or parent dir does not exist create it !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat)) // or we are not allowed to create it { self::_remove_password($url); @@ -609,15 +609,15 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface $to_dir = Vfs::dirname($path_to); $operation = self::url2operation($url_from); - if (!($from_stat = static::url_stat($path_from, 0)) || !$from_dir || - !Vfs::check_access($from_dir, Vfs::WRITABLE, $from_dir_stat = static::url_stat($from_dir, 0))) + if (!($from_stat = $this->url_stat($path_from, 0)) || !$from_dir || + !Vfs::check_access($from_dir, Vfs::WRITABLE, $from_dir_stat = $this->url_stat($from_dir, 0))) { self::_remove_password($url_from); self::_remove_password($url_to); if (self::LOG_LEVEL) error_log(__METHOD__."($url_from,$url_to): $path_from permission denied!"); return false; // no permission or file does not exist } - if (!$to_dir || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = static::url_stat($to_dir, 0))) + if (!$to_dir || !Vfs::check_access($to_dir, Vfs::WRITABLE, $to_dir_stat = $this->url_stat($to_dir, 0))) { self::_remove_password($url_from); self::_remove_password($url_to); @@ -626,7 +626,7 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface } // the filesystem stream-wrapper does NOT allow to rename files to directories, as this makes problems // for our vfs too, we abort here with an error, like the filesystem one does - if (($to_stat = static::url_stat($path_to, 0)) && + if (($to_stat = $this->url_stat($path_to, 0)) && ($to_stat['mime'] === self::DIR_MIME_TYPE) !== ($from_stat['mime'] === self::DIR_MIME_TYPE)) { self::_remove_password($url_from); @@ -796,7 +796,7 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface if (!($parent = Vfs::dirname($path)) || !($stat = $this->url_stat($path, 0)) || $stat['mime'] != self::DIR_MIME_TYPE || - !Vfs::check_access($parent, Vfs::WRITABLE, static::url_stat($parent,0))) + !Vfs::check_access($parent, Vfs::WRITABLE, $this->url_stat($parent,0))) { self::_remove_password($url); $err_msg = __METHOD__."($url,$options) ".(!$stat ? 'not found!' : @@ -1350,14 +1350,14 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface { if (self::LOG_LEVEL > 1) error_log(__METHOD__."('$target','$link')"); - $vfs = new self(); - if ($vfs->url_stat($link,0)) + $inst = new static(); + if ($inst->url_stat($link,0)) { if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') $link exists, returning false!"); return false; // $link already exists } if (!($dir = Vfs::dirname($link)) || - !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=static::url_stat($dir,0))) + !Vfs::check_access($dir,Vfs::WRITABLE,$dir_stat=$inst->url_stat($dir,0))) { if (self::LOG_LEVEL > 0) error_log(__METHOD__."('$target','$link') returning false! (!is_writable('$dir'), dir_stat=".array2string($dir_stat).")"); return false; // parent dir does not exist or is not writable @@ -1526,7 +1526,8 @@ class StreamWrapper extends Api\Db\Pdo implements Vfs\StreamWrapperIface */ static function get_eacl($path) { - if (!($stat = static::url_stat($path, STREAM_URL_STAT_QUIET))) + $inst = new static(); + if (!($stat = $inst->url_stat($path, STREAM_URL_STAT_QUIET))) { error_log(__METHOD__.__LINE__.' '.array2string($path).' not found!'); return false; // not found