From f17e7950048cea156d6335c1988be22c34655d74 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 16 Jan 2024 10:30:26 +0100 Subject: [PATCH] fix: don't crash if a duplicate is found on search and episode --- lib/Controller/EpisodesController.php | 2 +- lib/Controller/SearchController.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Controller/EpisodesController.php b/lib/Controller/EpisodesController.php index 74597b5..088ff83 100644 --- a/lib/Controller/EpisodesController.php +++ b/lib/Controller/EpisodesController.php @@ -34,7 +34,7 @@ class EpisodesController extends Controller $episodes = $this->episodeActionReader->parseRssXml((string) $feed->getBody()); usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b) => $b->getPubDate() <=> $a->getPubDate()); - $episodes = array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode) => $episode->getGuid(), $episodes))); + $episodes = array_values(array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode) => $episode->getGuid(), $episodes)))); return new JSONResponse($episodes, $feed->getStatusCode()); } diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php index dac90f2..3c808c3 100644 --- a/lib/Controller/SearchController.php +++ b/lib/Controller/SearchController.php @@ -37,7 +37,7 @@ class SearchController extends Controller } usort($podcasts, fn (PodcastData $a, PodcastData $b) => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix()); - $podcasts = array_intersect_key($podcasts, array_unique(array_map(fn (PodcastData $feed) => $feed->getLink(), $podcasts))); + $podcasts = array_values(array_intersect_key($podcasts, array_unique(array_map(fn (PodcastData $feed) => $feed->getLink(), $podcasts)))); return new JSONResponse($podcasts); }