From e282e8e8f8ccb632041a135d116075365b8584c5 Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Sat, 21 Oct 2023 11:14:51 +0200 Subject: [PATCH] Do not crash when viewing an internal error for a deleted judgehost. Fixes #1809. --- webapp/src/Controller/Jury/InternalErrorController.php | 6 +++++- webapp/templates/jury/internal_error.html.twig | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/webapp/src/Controller/Jury/InternalErrorController.php b/webapp/src/Controller/Jury/InternalErrorController.php index adb4bd971f..1c7fc250ca 100644 --- a/webapp/src/Controller/Jury/InternalErrorController.php +++ b/webapp/src/Controller/Jury/InternalErrorController.php @@ -103,8 +103,12 @@ public function viewAction(int $errorId): Response case 'judgehost': // Judgehosts get disabled by their hostname, so we need to look it up here. $judgehost = $this->em->getRepository(Judgehost::class)->findOneBy(['hostname' => $disabled['hostname']]); - $affectedLink = $this->generateUrl('jury_judgehost', ['judgehostid' => $judgehost->getJudgehostid()]); $affectedText = $disabled['hostname']; + if ($judgehost) { + $affectedLink = $this->generateUrl('jury_judgehost', ['judgehostid' => $judgehost->getJudgehostid()]); + } else { + $affectedText .= ' (deleted)'; + } break; case 'language': $affectedLink = $this->generateUrl('jury_language', ['langId' => $disabled['langid']]); diff --git a/webapp/templates/jury/internal_error.html.twig b/webapp/templates/jury/internal_error.html.twig index 3ba03ea3d8..fb809430ac 100644 --- a/webapp/templates/jury/internal_error.html.twig +++ b/webapp/templates/jury/internal_error.html.twig @@ -72,7 +72,13 @@ {% if affectedText is not null %} Affected {{ internalError.disabled.kind }} - {{ affectedText }} + + {% if affectedLink %} + {{ affectedText }} + {% else %} + {{ affectedText }} + {% endif %} + {% endif %}