fix: don't crash if a duplicate is found on search and episode
All checks were successful
repod / xml (push) Successful in 13s
repod / php (push) Successful in 49s
repod / nodejs (push) Successful in 1m42s
repod / release (push) Has been skipped

This commit is contained in:
Michel Roux 2024-01-16 10:30:26 +01:00
parent 80844d8ac0
commit f17e795004
2 changed files with 2 additions and 2 deletions

View File

@ -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());
}

View File

@ -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);
}