Do not crash when only few games exist
authorChristian Weiske <cweiske@cweiske.de>
Tue, 9 Jun 2020 18:57:47 +0000 (20:57 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 9 Jun 2020 18:57:47 +0000 (20:57 +0200)
bin/filters.php

index a10777a03ed65bcec36ed507da65c6dc93a30e2b..107714d7ca5d5afbfe73354771225aea4b12f3e3 100644 (file)
@@ -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];