From 0074647b2114b245d176af64bbf5b4cfd2b5a003 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 9 Nov 2022 22:34:58 -0800 Subject: [PATCH] apibase: fix getuserfile --- lib/Controller/ApiBase.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Controller/ApiBase.php b/lib/Controller/ApiBase.php index 1dcd4336..072ab26d 100644 --- a/lib/Controller/ApiBase.php +++ b/lib/Controller/ApiBase.php @@ -134,7 +134,14 @@ class ApiBase extends Controller return $folder; } - protected function getUserFile(int $id): File + /** + * Get a file with ID from user's folder + * + * @param int $fileId + * + * @return File|null + */ + protected function getUserFile(int $id) { $user = $this->userSession->getUser(); if (null === $user) { @@ -148,6 +155,11 @@ class ApiBase extends Controller return null; } + // Check if node is a file + if (!($file[0] instanceof File)) { + return null; + } + return $file[0]; }