From f6b66cf7006b4b14c15a09aedace434c58ed9d31 Mon Sep 17 00:00:00 2001 From: MCJ Vasseur <14887731+vmcj@users.noreply.github.com> Date: Sun, 13 Oct 2024 14:21:27 +0200 Subject: [PATCH] Fix judgehost check if its enabled array_filter would only filter out the other judgehosts but still return an array of judgehost objects. By selecting the first (and only item) we can now get the `enabled` property and properly check. ``` array(1) { [1]=> array(5) { ["id"]=> string(1) "2" ["hostname"]=> string(8) "judgehost" ["enabled"]=> bool(true) ["polltime"]=> string(20) "1728821560.017400000" ["hidden"]=> bool(false) } } ``` --- judge/judgedaemon.main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/judge/judgedaemon.main.php b/judge/judgedaemon.main.php index b2ab57385b..8f4a44c068 100644 --- a/judge/judgedaemon.main.php +++ b/judge/judgedaemon.main.php @@ -768,7 +768,7 @@ function fetch_executable_internal( $judgehosts = request('judgehosts', 'GET'); if ($judgehosts !== null) { $judgehosts = dj_json_decode($judgehosts); - $judgehost = array_filter($judgehosts, fn($j) => $j['hostname'] === $myhost); + $judgehost = array_values(array_filter($judgehosts, fn($j) => $j['hostname'] === $myhost))[0]; if (!isset($judgehost['enabled']) || !$judgehost['enabled']) { logmsg(LOG_WARNING, "Judgehost needs to be enabled in web interface."); }