From 704bd95608b15e66046e92aa03fdff9d55dbffb0 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Fri, 5 Aug 2022 15:28:21 +0200 Subject: [PATCH] Fix WSOD when Renderer throws exception `HTTPException` builds a simple static version of error page if `Renderer` throws any exception while rendering the error page. --- src/Module/Special/HTTPException.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Module/Special/HTTPException.php b/src/Module/Special/HTTPException.php index 8b520f6b5a..0cd7817ed4 100644 --- a/src/Module/Special/HTTPException.php +++ b/src/Module/Special/HTTPException.php @@ -70,8 +70,17 @@ class HTTPException $content = ''; if ($e->getCode() >= 400) { - $tpl = Renderer::getMarkupTemplate('http_status.tpl'); - $content = Renderer::replaceMacros($tpl, self::getVars($e)); + $vars = self::getVars($e); + try { + $tpl = Renderer::getMarkupTemplate('http_status.tpl'); + $content = Renderer::replaceMacros($tpl, $vars); + } catch (\Exception $e) { + $content = "

{$vars['$title']}

{$vars['$message']}

"; + if (DI::app()->isSiteAdmin()) { + $content .= "

{$vars['$thrown']}

"; + $content .= "
{$vars['$trace']}
"; + } + } } System::httpError($e->getCode(), $e->getDescription(), $content);