Skip to content

Commit

Permalink
Fix judgehost check if its enabled
Browse files Browse the repository at this point in the history
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)
  }
}
```
  • Loading branch information
vmcj committed Oct 22, 2024
1 parent fccf20c commit f6b66cf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down

0 comments on commit f6b66cf

Please sign in to comment.