diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c28c296..184f5d6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. - [#194](https://github.com/os2display/display-api-service/pull/194) Updated test run documentation and added test for `rrule` in playlist. +- Fixed issue with PlaylistSlide transaction. - Fixed issues with feed following api platform upgrade. - [#192](https://github.com/os2display/display-api-service/pull/192) - Fix env value typo's diff --git a/src/Repository/PlaylistSlideRepository.php b/src/Repository/PlaylistSlideRepository.php index 7e67d141..3e7c340c 100644 --- a/src/Repository/PlaylistSlideRepository.php +++ b/src/Repository/PlaylistSlideRepository.php @@ -69,6 +69,8 @@ public function getPlaylistsFromSlideId(Ulid $id): QueryBuilder public function updatePlaylistSlideRelations(Ulid $playlistUlid, ArrayCollection $collection, Tenant $tenant): void { + $this->entityManager->getConnection()->beginTransaction(); + $playlistRepos = $this->entityManager->getRepository(Playlist::class); $playlist = $playlistRepos->findOneBy(['id' => $playlistUlid, 'tenant' => $tenant]); @@ -78,8 +80,6 @@ public function updatePlaylistSlideRelations(Ulid $playlistUlid, ArrayCollection $slideRepos = $this->entityManager->getRepository(Slide::class); - $this->entityManager->getConnection()->beginTransaction(); - try { $entities = $this->findBy(['playlist' => $playlistUlid]); $slideIdsToAdd = array_map(fn ($entry) => $entry->slide, $collection->toArray()); diff --git a/tests/Api/PlaylistSlideTest.php b/tests/Api/PlaylistSlideTest.php index 36796c32..795e6ab3 100644 --- a/tests/Api/PlaylistSlideTest.php +++ b/tests/Api/PlaylistSlideTest.php @@ -100,9 +100,9 @@ public function testLinkSlideToPlaylist(): void $iri = $this->findIriBy(Playlist::class, ['tenant' => $this->tenant]); $playlistUlid = $this->iriHelperUtils->getUlidFromIRI($iri); - $iri = $this->findIriBy(Slide::class, ['tenant' => $this->tenant]); + $iri = $this->findIriBy(Slide::class, ['tenant' => $this->tenant, 'title' => 'slide_abc_2']); $slideUlid1 = $this->iriHelperUtils->getUlidFromIRI($iri); - $iri = $this->findIriBy(Slide::class, ['tenant' => $this->tenant]); + $iri = $this->findIriBy(Slide::class, ['tenant' => $this->tenant, 'title' => 'slide_abc_3']); $slideUlid2 = $this->iriHelperUtils->getUlidFromIRI($iri); $client->request('PUT', '/v1/playlists/'.$playlistUlid.'/slides', [