aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprovokateurin <kate@provokateurin.de>2025-01-06 12:47:21 +0100
committerprovokateurin <kate@provokateurin.de>2025-01-13 15:21:20 +0100
commit9f59204148dd2393224b6dbfb8c02760541ed54c (patch)
treeb267f151e6c01d02fd354d8c5e5d2d9e2f9fc344
parent4dfa02c29d9a5f4e2cd4a6a8a989fad716222c24 (diff)
downloadnextcloud-server-9f59204148dd2393224b6dbfb8c02760541ed54c.tar.gz
nextcloud-server-9f59204148dd2393224b6dbfb8c02760541ed54c.zip
fix(files_sharing): Gracefully handle fetching non-existent share
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r--apps/files_sharing/lib/External/Manager.php19
1 files changed, 5 insertions, 14 deletions
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index 1ea7775641e..ff7f2dd3c48 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -160,13 +160,7 @@ class Manager {
$query->execute([$remote, $token, $password, $name, $owner, $user, $mountPoint, $hash, $accepted, $remoteId, $parent, $shareType]);
}
- /**
- * get share
- *
- * @param int $id share id
- * @return mixed share of false
- */
- private function fetchShare($id) {
+ private function fetchShare(int $id): array|false {
$getShare = $this->connection->prepare('
SELECT `id`, `remote`, `remote_id`, `share_token`, `name`, `owner`, `user`, `mountpoint`, `accepted`, `parent`, `share_type`, `password`, `mountpoint_hash`
FROM `*PREFIX*share_external`
@@ -208,15 +202,12 @@ class Manager {
return null;
}
- /**
- * get share
- *
- * @param int $id share id
- * @return mixed share of false
- */
public function getShare(int $id, ?string $user = null): array|false {
$user = $user ?? $this->uid;
$share = $this->fetchShare($id);
+ if ($share === false) {
+ return false;
+ }
// check if the user is allowed to access it
if ($this->canAccessShare($share, $user)) {
@@ -256,7 +247,7 @@ class Manager {
&& $share['user'] === $user) {
return true;
}
-
+
// If the share is a group share, check if the user is in the group
if ((int)$share['share_type'] === IShare::TYPE_GROUP) {
$parentId = (int)$share['parent'];