aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2024-09-16 16:00:30 +0200
committerprovokateurin <kate@provokateurin.de>2024-09-17 10:10:50 +0200
commit8ca6fcace7dc22230a7afe84936ca01470f50d00 (patch)
treefd6867b712621f7a9969bd190ef3b2f2499984d3
parentc256518ab3cb61d046ee10edf1c3b18218ee8ff6 (diff)
downloadnextcloud-server-8ca6fcace7dc22230a7afe84936ca01470f50d00.tar.gz
nextcloud-server-8ca6fcace7dc22230a7afe84936ca01470f50d00.zip
fix(Storage): Document getOwner() can return false
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--apps/dav/lib/Storage/PublicOwnerWrapper.php2
-rw-r--r--apps/files_sharing/lib/External/Storage.php2
-rw-r--r--apps/files_sharing/lib/SharedStorage.php2
-rw-r--r--lib/private/Files/ObjectStore/HomeObjectStoreStorage.php8
-rw-r--r--lib/private/Files/Storage/Common.php8
-rw-r--r--lib/private/Files/Storage/Home.php8
-rw-r--r--lib/private/Files/Storage/Wrapper/Availability.php4
-rw-r--r--lib/private/Files/Storage/Wrapper/Jail.php8
-rw-r--r--lib/private/Files/Storage/Wrapper/Wrapper.php9
-rw-r--r--lib/private/Files/View.php4
-rw-r--r--lib/private/Lockdown/Filesystem/NullStorage.php4
-rw-r--r--lib/public/Files/Storage/IStorage.php2
-rw-r--r--tests/lib/Lockdown/Filesystem/NullStorageTest.php2
13 files changed, 15 insertions, 48 deletions
diff --git a/apps/dav/lib/Storage/PublicOwnerWrapper.php b/apps/dav/lib/Storage/PublicOwnerWrapper.php
index 6523c4c7cad..40ef81ab06d 100644
--- a/apps/dav/lib/Storage/PublicOwnerWrapper.php
+++ b/apps/dav/lib/Storage/PublicOwnerWrapper.php
@@ -26,7 +26,7 @@ class PublicOwnerWrapper extends Wrapper {
$this->owner = $arguments['owner'];
}
- public function getOwner($path) {
+ public function getOwner($path): string|false {
$owner = parent::getOwner($path);
if ($owner === null || $owner === false) {
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index 169054fd1d9..9172ff93202 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -345,7 +345,7 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage,
return json_decode($response->getBody(), true);
}
- public function getOwner($path) {
+ public function getOwner($path): string|false {
return $this->cloudId->getDisplayId();
}
diff --git a/apps/files_sharing/lib/SharedStorage.php b/apps/files_sharing/lib/SharedStorage.php
index 62f5880294c..cecc1d5cb98 100644
--- a/apps/files_sharing/lib/SharedStorage.php
+++ b/apps/files_sharing/lib/SharedStorage.php
@@ -446,7 +446,7 @@ class SharedStorage extends \OC\Files\Storage\Wrapper\Jail implements LegacyISha
return new \OCA\Files_Sharing\Scanner($storage);
}
- public function getOwner($path): string {
+ public function getOwner($path): string|false {
return $this->superShare->getShareOwner();
}
diff --git a/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php b/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php
index b543d223f4c..feca1f6b4f5 100644
--- a/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php
+++ b/lib/private/Files/ObjectStore/HomeObjectStoreStorage.php
@@ -32,13 +32,7 @@ class HomeObjectStoreStorage extends ObjectStoreStorage implements IHomeStorage
return 'object::user:' . $this->user->getUID();
}
- /**
- * get the owner of a path
- *
- * @param string $path The path to get the owner
- * @return string uid
- */
- public function getOwner($path): string {
+ public function getOwner($path): string|false {
return $this->user->getUID();
}
diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php
index eb93ab89bc7..181da79cebe 100644
--- a/lib/private/Files/Storage/Common.php
+++ b/lib/private/Files/Storage/Common.php
@@ -390,13 +390,7 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
return $this->getCache($storage)->getStorageCache();
}
- /**
- * get the owner of a path
- *
- * @param string $path The path to get the owner
- * @return string|false uid or false
- */
- public function getOwner($path) {
+ public function getOwner($path): string|false {
if ($this->owner === null) {
$this->owner = \OC_User::getUser();
}
diff --git a/lib/private/Files/Storage/Home.php b/lib/private/Files/Storage/Home.php
index 0e53e7b28d4..f7151f4a005 100644
--- a/lib/private/Files/Storage/Home.php
+++ b/lib/private/Files/Storage/Home.php
@@ -83,13 +83,7 @@ class Home extends Local implements \OCP\Files\IHomeStorage {
return $this->user;
}
- /**
- * get the owner of a path
- *
- * @param string $path The path to get the owner
- * @return string uid or false
- */
- public function getOwner($path) {
+ public function getOwner($path): string|false {
return $this->user->getUID();
}
}
diff --git a/lib/private/Files/Storage/Wrapper/Availability.php b/lib/private/Files/Storage/Wrapper/Availability.php
index 6bd622e1c1b..0f1abada168 100644
--- a/lib/private/Files/Storage/Wrapper/Availability.php
+++ b/lib/private/Files/Storage/Wrapper/Availability.php
@@ -373,12 +373,12 @@ class Availability extends Wrapper {
}
}
- /** {@inheritdoc} */
- public function getOwner($path) {
+ public function getOwner($path): string|false {
try {
return parent::getOwner($path);
} catch (StorageNotAvailableException $e) {
$this->setUnavailable($e);
+ return false;
}
}
diff --git a/lib/private/Files/Storage/Wrapper/Jail.php b/lib/private/Files/Storage/Wrapper/Jail.php
index 5673caf834a..46b40b92244 100644
--- a/lib/private/Files/Storage/Wrapper/Jail.php
+++ b/lib/private/Files/Storage/Wrapper/Jail.php
@@ -370,13 +370,7 @@ class Jail extends Wrapper {
return new CacheJail($sourceCache, $this->rootPath);
}
- /**
- * get the user id of the owner of a file or folder
- *
- * @param string $path
- * @return string
- */
- public function getOwner($path) {
+ public function getOwner($path): string|false {
return $this->getWrapperStorage()->getOwner($this->getUnjailedPath($path));
}
diff --git a/lib/private/Files/Storage/Wrapper/Wrapper.php b/lib/private/Files/Storage/Wrapper/Wrapper.php
index f0420f4f16a..2a6d04da849 100644
--- a/lib/private/Files/Storage/Wrapper/Wrapper.php
+++ b/lib/private/Files/Storage/Wrapper/Wrapper.php
@@ -381,14 +381,7 @@ class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage, IWriteStrea
return $this->getWrapperStorage()->getScanner($path, $storage);
}
-
- /**
- * get the user id of the owner of a file or folder
- *
- * @param string $path
- * @return string
- */
- public function getOwner($path) {
+ public function getOwner($path): string|false {
return $this->getWrapperStorage()->getOwner($path);
}
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 336349c680b..9ac74461ca8 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -1676,11 +1676,9 @@ class View {
/**
* Get the owner for a file or folder
*
- * @param string $path
- * @return string the user id of the owner
* @throws NotFoundException
*/
- public function getOwner($path) {
+ public function getOwner(string $path): string {
$info = $this->getFileInfo($path);
if (!$info) {
throw new NotFoundException($path . ' not found while trying to get owner');
diff --git a/lib/private/Lockdown/Filesystem/NullStorage.php b/lib/private/Lockdown/Filesystem/NullStorage.php
index 7175594a01d..00124877e9d 100644
--- a/lib/private/Lockdown/Filesystem/NullStorage.php
+++ b/lib/private/Lockdown/Filesystem/NullStorage.php
@@ -155,8 +155,8 @@ class NullStorage extends Common {
return true;
}
- public function getOwner($path) {
- return null;
+ public function getOwner($path): string|false {
+ return false;
}
public function getCache($path = '', $storage = null) {
diff --git a/lib/public/Files/Storage/IStorage.php b/lib/public/Files/Storage/IStorage.php
index d2fd3b75553..2016c273f91 100644
--- a/lib/public/Files/Storage/IStorage.php
+++ b/lib/public/Files/Storage/IStorage.php
@@ -414,7 +414,7 @@ interface IStorage {
/**
* @param string $path path for which to retrieve the owner
- * @return string
+ * @return string|false
* @since 9.0.0
*/
public function getOwner($path);
diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
index cc65221d0a3..a0b9b04ad1a 100644
--- a/tests/lib/Lockdown/Filesystem/NullStorageTest.php
+++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
@@ -219,7 +219,7 @@ class NullStorageTest extends TestCase {
}
public function testGetOwner(): void {
- $this->assertNull($this->storage->getOwner('foo'));
+ $this->assertFalse($this->storage->getOwner('foo'));
}
public function testGetCache(): void {