From 0c3c041dbbd0a91ff529faee8a489c1d0d155efe Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 21 Jul 2016 11:17:01 +0200 Subject: [PATCH] fix rename and load_wrapper missing in Vfs class --- api/src/Vfs.php | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/api/src/Vfs.php b/api/src/Vfs.php index 8f6a57c6a7..ec85fff181 100644 --- a/api/src/Vfs.php +++ b/api/src/Vfs.php @@ -771,6 +771,8 @@ class Vfs */ static function check_access($path, $check, $stat=null, $user=null) { + static $vfs = null; + if (is_null($stat) && $user && $user != self::$user) { static $path_user_stat = array(); @@ -782,7 +784,7 @@ class Vfs { self::clearstatcache($path); - $vfs = new Vfs\StreamWrapper(); + if (!isset($vfs)) $vfs = new Vfs\StreamWrapper(); $path_user_stat[$path][$user] = $vfs->url_stat($path, 0); self::clearstatcache($path); // we need to clear the stat-cache after the call too, as the next call might be the regular user again! @@ -2369,7 +2371,7 @@ class Vfs { if (($ret = self::_call_on_backend('symlink',array($target,$link),false,1))) // 1=path is in $link! { - self::symlinkCache_remove($link); + Vfs\StreamWrapper::symlinkCache_remove($link); } return $ret; } @@ -2458,6 +2460,35 @@ class Vfs self::_call_on_backend('clearstatcache', array($path), true, 0); Vfs\StreamWrapper::clearstatcache($path); } + + /** + * This method is called in response to rename() calls on URL paths associated with the wrapper. + * + * It should attempt to rename the item specified by path_from to the specification given by path_to. + * In order for the appropriate error message to be returned, do not define this method if your wrapper does not support renaming. + * + * The regular filesystem stream-wrapper returns an error, if $url_from and $url_to are not either both files or both dirs! + * + * @param string $path_from + * @param string $path_to + * @return boolean TRUE on success or FALSE on failure + */ + function rename ( $path_from, $path_to ) + { + $vfs = new Vfs\StreamWrapper(); + return $vfs->rename($path_from, $path_to); + } + + /** + * Load stream wrapper for a given schema + * + * @param string $scheme + * @return boolean + */ + static function load_wrapper($scheme) + { + return Vfs\StreamWrapper::load_wrapper($scheme); + } } Vfs::init_static();