]> git.mxchange.org Git - friendica.git/commitdiff
Fix WSOD when Renderer throws exception
authorfabrixxm <fabrixxm@kirgroup.net>
Fri, 5 Aug 2022 13:28:21 +0000 (15:28 +0200)
committerfabrixxm <fabrixxm@kirgroup.net>
Fri, 5 Aug 2022 13:28:21 +0000 (15:28 +0200)
`HTTPException` builds a simple static version of error page if
`Renderer` throws any exception while rendering the error page.

src/Module/Special/HTTPException.php

index 8b520f6b5af68554d59924c24d0d0449b09b3d36..0cd7817ed4de05017a3156d0e98d5ecb1805c7a8 100644 (file)
@@ -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 = "<h1>{$vars['$title']}</h1><p>{$vars['$message']}</p>";
+                               if (DI::app()->isSiteAdmin()) {
+                                       $content .= "<p>{$vars['$thrown']}</p>";
+                                       $content .= "<pre>{$vars['$trace']}</pre>";
+                               }
+                       }
                }
 
                System::httpError($e->getCode(), $e->getDescription(), $content);