From ff0220b35e254625eb45bc764c0d86e99f27e924 Mon Sep 17 00:00:00 2001
From: Jan-Hendrik Willms <tleilax+studip@gmail.com>
Date: Mon, 8 Jul 2024 18:25:40 +0000
Subject: [PATCH] fix php8 warnings and variable access in stock images routes,
 fixes #4378

Closes #4378

Merge request studip/studip!3184
---
 lib/classes/JsonApi/Routes/StockImages/StockImagesCreate.php | 4 ++--
 lib/classes/JsonApi/Routes/StockImages/StockImagesUpdate.php | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/classes/JsonApi/Routes/StockImages/StockImagesCreate.php b/lib/classes/JsonApi/Routes/StockImages/StockImagesCreate.php
index 5c11a9e0466..50ebd55842e 100644
--- a/lib/classes/JsonApi/Routes/StockImages/StockImagesCreate.php
+++ b/lib/classes/JsonApi/Routes/StockImages/StockImagesCreate.php
@@ -25,9 +25,9 @@ class StockImagesCreate extends JsonApiController
      */
     public function __invoke(Request $request, Response $response, $args): Response
     {
-        $json = $this->validate($request, $resource);
+        $json = $this->validate($request);
         $user = $this->getUser($request);
-        if (!Authority::canCreateStockImage($user, $resource)) {
+        if (!Authority::canCreateStockImage($user)) {
             throw new AuthorizationFailedException();
         }
         $resource = $this->createResource($json);
diff --git a/lib/classes/JsonApi/Routes/StockImages/StockImagesUpdate.php b/lib/classes/JsonApi/Routes/StockImages/StockImagesUpdate.php
index cef9db5cac7..e52370587a3 100644
--- a/lib/classes/JsonApi/Routes/StockImages/StockImagesUpdate.php
+++ b/lib/classes/JsonApi/Routes/StockImages/StockImagesUpdate.php
@@ -84,7 +84,7 @@ class StockImagesUpdate extends JsonApiController
         }
     }
 
-    private function updateResource(StockImage $resource, array $json): void
+    private function updateResource(StockImage $resource, array $json): StockImage
     {
         $updates = array_merge(
             self::getAttributeUpdates($json, ['title', 'description', 'author', 'license']),
@@ -92,5 +92,7 @@ class StockImagesUpdate extends JsonApiController
         );
         $resource->setData($updates);
         $resource->store();
+
+        return $resource;
     }
 }
-- 
GitLab