diff options
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/view.php | 25 | ||||
-rw-r--r-- | lib/private/memcache/memcached.php | 38 |
2 files changed, 50 insertions, 13 deletions
diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 7dd83588ec6..cee4b182425 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -46,11 +46,13 @@ namespace OC\Files; use Icewind\Streams\CallbackWrapper; use OC\Files\Cache\Updater; use OC\Files\Mount\MoveableMount; +use OC\User\User; use OCP\Files\FileNameTooLongException; use OCP\Files\InvalidCharacterInPathException; use OCP\Files\InvalidPathException; use OCP\Files\NotFoundException; use OCP\Files\ReservedWordException; +use OCP\IUser; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; @@ -687,14 +689,14 @@ class View { } else { $result = false; } - // moving a file/folder within the same mount point + // moving a file/folder within the same mount point } elseif ($storage1 == $storage2) { if ($storage1) { $result = $storage1->rename($internalPath1, $internalPath2); } else { $result = false; } - // moving a file/folder between storages (from $storage1 to $storage2) + // moving a file/folder between storages (from $storage1 to $storage2) } else { $result = $storage2->moveFromStorage($storage1, $internalPath1, $internalPath2); } @@ -1164,6 +1166,19 @@ class View { } /** + * @param string $ownerId + * @return \OC\User\User + */ + private function getUserObjectForOwner($ownerId) { + $owner = \OC::$server->getUserManager()->get($ownerId); + if ($owner instanceof IUser) { + return $owner; + } else { + return new User($ownerId, null); + } + } + + /** * get the filesystem info * * @param string $path @@ -1250,7 +1265,7 @@ class View { $data['permissions'] |= \OCP\Constants::PERMISSION_DELETE; } - $owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath)); + $owner = $this->getUserObjectForOwner($storage->getOwner($internalPath)); return new FileInfo($path, $storage, $internalPath, $data, $mount, $owner); } @@ -1317,7 +1332,7 @@ class View { if (\OCP\Util::isSharingDisabledForUser()) { $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; } - $owner = \OC::$server->getUserManager()->get($storage->getOwner($content['path'])); + $owner = $this->getUserObjectForOwner($storage->getOwner($content['path'])); $files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner); } @@ -1387,7 +1402,7 @@ class View { $rootEntry['permissions'] = $rootEntry['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; } - $owner = \OC::$server->getUserManager()->get($subStorage->getOwner('')); + $owner = $this->getUserObjectForOwner($subStorage->getOwner('')); $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner); } } diff --git a/lib/private/memcache/memcached.php b/lib/private/memcache/memcached.php index ce7c6fa9577..22b54f7bc95 100644 --- a/lib/private/memcache/memcached.php +++ b/lib/private/memcache/memcached.php @@ -41,9 +41,9 @@ class Memcached extends Cache implements IMemcache { parent::__construct($prefix); if (is_null(self::$cache)) { self::$cache = new \Memcached(); - $servers = \OC_Config::getValue('memcached_servers'); + $servers = \OC::$server->getSystemConfig()->getValue('memcached_servers'); if (!$servers) { - $server = \OC_Config::getValue('memcached_server'); + $server = \OC::$server->getSystemConfig()->getValue('memcached_server'); if ($server) { $servers = array($server); } else { @@ -72,10 +72,12 @@ class Memcached extends Cache implements IMemcache { public function set($key, $value, $ttl = 0) { if ($ttl > 0) { - return self::$cache->set($this->getNamespace() . $key, $value, $ttl); + $result = self::$cache->set($this->getNamespace() . $key, $value, $ttl); } else { - return self::$cache->set($this->getNamespace() . $key, $value); + $result = self::$cache->set($this->getNamespace() . $key, $value); } + $this->verifyReturnCode(); + return $result; } public function hasKey($key) { @@ -84,7 +86,9 @@ class Memcached extends Cache implements IMemcache { } public function remove($key) { - return self::$cache->delete($this->getNamespace() . $key); + $result= self::$cache->delete($this->getNamespace() . $key); + $this->verifyReturnCode(); + return $result; } public function clear($prefix = '') { @@ -121,7 +125,9 @@ class Memcached extends Cache implements IMemcache { * @return bool */ public function add($key, $value, $ttl = 0) { - return self::$cache->add($this->getPrefix() . $key, $value, $ttl); + $result = self::$cache->add($this->getPrefix() . $key, $value, $ttl); + $this->verifyReturnCode(); + return $result; } /** @@ -133,7 +139,9 @@ class Memcached extends Cache implements IMemcache { */ public function inc($key, $step = 1) { $this->add($key, 0); - return self::$cache->increment($this->getPrefix() . $key, $step); + $result = self::$cache->increment($this->getPrefix() . $key, $step); + $this->verifyReturnCode(); + return $result; } /** @@ -144,10 +152,24 @@ class Memcached extends Cache implements IMemcache { * @return int | bool */ public function dec($key, $step = 1) { - return self::$cache->decrement($this->getPrefix() . $key, $step); + $result = self::$cache->decrement($this->getPrefix() . $key, $step); + $this->verifyReturnCode(); + return $result; } static public function isAvailable() { return extension_loaded('memcached'); } + + /** + * @throws \Exception + */ + private function verifyReturnCode() { + $code = self::$cache->getResultCode(); + if ($code === \Memcached::RES_SUCCESS) { + return; + } + $message = self::$cache->getResultMessage(); + throw new \Exception("Error $code interacting with memcached : $message"); + } } |