diff options
author | provokateurin <kate@provokateurin.de> | 2025-01-06 12:47:21 +0100 |
---|---|---|
committer | provokateurin <kate@provokateurin.de> | 2025-01-13 15:21:20 +0100 |
commit | 9f59204148dd2393224b6dbfb8c02760541ed54c (patch) | |
tree | b267f151e6c01d02fd354d8c5e5d2d9e2f9fc344 /apps/files_sharing/lib/External | |
parent | 4dfa02c29d9a5f4e2cd4a6a8a989fad716222c24 (diff) | |
download | nextcloud-server-9f59204148dd2393224b6dbfb8c02760541ed54c.tar.gz nextcloud-server-9f59204148dd2393224b6dbfb8c02760541ed54c.zip |
fix(files_sharing): Gracefully handle fetching non-existent share
Signed-off-by: provokateurin <kate@provokateurin.de>
Diffstat (limited to 'apps/files_sharing/lib/External')
-rw-r--r-- | apps/files_sharing/lib/External/Manager.php | 19 |
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']; |