From c99c8e534f25662f2c98630901ea43f25889421b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Tue, 21 Mar 2023 00:09:07 +0100 Subject: [PATCH] Don't panic when GH API does not return --- public/about.php | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/public/about.php b/public/about.php index 2f6df48c..53577906 100644 --- a/public/about.php +++ b/public/about.php @@ -55,24 +55,26 @@ function url_get_contents($Url) return $output; } - // Cache the contributors - if (!getRedis("contributors")) { - $contributorsResponse = url_get_contents("https://api.github.com/repos/interclip/interclip/contributors", false); - $contributorsJSON = json_decode($contributorsResponse, true); - - // Get the login of every contributor - $contributors = array(); - foreach ($contributorsJSON as $contributor) { - // Don't push if the contributor is a bot - if ($contributor['type'] !== "Bot" && !str_contains(strtolower($contributor['login']), "bot")) { - array_push($contributors, $contributor['login']); + try { + if (!getRedis("contributors")) { + $contributorsResponse = url_get_contents("https://api.github.com/repos/interclip/interclip/contributors", false); + $contributorsJSON = json_decode($contributorsResponse, true); + + // Get the login of every contributor + $contributors = array(); + foreach ($contributorsJSON as $contributor) { + // Don't push if the contributor is a bot + if ($contributor['type'] !== "Bot" && !str_contains(strtolower($contributor['login']), "bot")) { + array_push($contributors, $contributor['login']); + } } - } - // Cache the contributors - storeRedis("contributors", json_encode($contributors), 60 * 60 * 24); - } else { - $contributors = json_decode(getRedis("contributors")); + // Cache the contributors + storeRedis("contributors", json_encode($contributors), 60 * 60 * 24); + } else { + $contributors = json_decode(getRedis("contributors")); + } + } catch (Error $e) { } ?>