From 0060f2316ca1cc2f9eea520ef0a4628c0a99c702 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Witold=20Wis=CC=81niewski?= Date: Wed, 27 Mar 2024 14:11:13 +0100 Subject: [PATCH] Fix edit content --- src/Repositories/H5PContentRepository.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Repositories/H5PContentRepository.php b/src/Repositories/H5PContentRepository.php index 535a3e9..50b94ef 100644 --- a/src/Repositories/H5PContentRepository.php +++ b/src/Repositories/H5PContentRepository.php @@ -68,13 +68,8 @@ public function create(string $library, string $params, string $nonce): int public function edit(int $id, string $library, string $params, string $nonce): int { - $libNames = $this->hh5pService->getCore()->libraryFromString($library); - - $libDb = H5PLibrary::where([ - ['name', $libNames['machineName']], - ['major_version', $libNames['majorVersion']], - ['minor_version', $libNames['minorVersion']], - ])->latest()->first(); + $content = H5PContent::where('id', $id)->first(); + $libDb = H5PLibrary::where('id', $content->library_id)->first(); if ($libDb === null) { throw new H5PException(H5PException::LIBRARY_NOT_FOUND); @@ -86,8 +81,6 @@ public function edit(int $id, string $library, string $params, string $nonce): i throw new H5PException(H5PException::INVALID_PARAMETERS_JSON); } - $content = H5PContent::where('id', $id)->first(); - if ($content === null) { throw new H5PException(H5PException::CONTENT_NOT_FOUND); }