From: Christian Weiske Date: Tue, 9 Jun 2020 18:57:47 +0000 (+0200) Subject: Do not crash when only few games exist X-Git-Tag: v3.0.0~33 X-Git-Url: https://git.cweiske.de/stouyapi.git/commitdiff_plain/7287030317ae7045440df94e557e25a4bc6f9890?hp=e6594fef1cf6490413c5a680efa298c99effb731;ds=sidebyside Do not crash when only few games exist --- diff --git a/bin/filters.php b/bin/filters.php index a10777a..107714d 100644 --- a/bin/filters.php +++ b/bin/filters.php @@ -117,7 +117,7 @@ function filterMostDownloaded($origGames, $limit) function filterRandom($origGames, $limit) { - $randKeys = array_rand($origGames, $limit); + $randKeys = array_rand($origGames, min(count($origGames), $limit)); $games = []; foreach ($randKeys as $key) { $games[] = $origGames[$key];