From ee22b29fa8ee49e5947c2b6144b007606dd85bb7 Mon Sep 17 00:00:00 2001 From: Marius Henker Date: Mon, 28 Aug 2023 09:55:54 +0200 Subject: [PATCH] Avoid error on CORS requests (#466) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix for #465 Made constructor parameter $userId of type `?string` (= be optional) If no userId is passed (aka. is null), $this->userId is set to an empty string to not cause any problems or errors. Signed-off-by: Marius H. * Add suggestion Commit suggestion from @juliushaertl Co-authored-by: Julius Härtl Signed-off-by: Marius H. * Avoid TypeErrors in Api1Controller Make `Api1Controller->userId` nullable to supress errors/warnings when assigning `null` to it Signed-off-by: Marius H. --------- Signed-off-by: Marius H. Co-authored-by: Julius Härtl --- lib/Controller/Api1Controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Controller/Api1Controller.php b/lib/Controller/Api1Controller.php index dc0bbeb85..c3540286d 100644 --- a/lib/Controller/Api1Controller.php +++ b/lib/Controller/Api1Controller.php @@ -27,7 +27,7 @@ class Api1Controller extends ApiController { private V1Api $v1Api; - private string $userId; + private ?string $userId; protected LoggerInterface $logger; @@ -45,7 +45,7 @@ public function __construct( ViewMapper $viewMapper, V1Api $v1Api, LoggerInterface $logger, - string $userId + ?string $userId ) { parent::__construct(Application::APP_ID, $request); $this->tableService = $service;