From 224b33201f1c7e7264025444cce2e3fe976ef487 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 24 May 2022 08:00:21 -0700 Subject: [PATCH] Fixed #11108 part 2 --- CHANGELOG.md | 1 + src/web/TemplateResponseFormatter.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca0a3a55f22..65edac35aa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Fixed - Fixed a bug where it wasn’t possible to disable all table columns for an element source. ([#11291](https://github.com/craftcms/cms/issues/11291)) - Fixed a bug where the Assets index page wasn’t allowing any bulk actions for assets in the temporary volume. ([#11293](https://github.com/craftcms/cms/issues/11293)) +- Fixed a bug where PHP parse errors thrown while rendering a template weren’t being handled properly. ([#11108](https://github.com/craftcms/cms/issues/11108)) ## 4.0.3 - 2022-05-20 diff --git a/src/web/TemplateResponseFormatter.php b/src/web/TemplateResponseFormatter.php index 8f310399920..83e312c4a5e 100644 --- a/src/web/TemplateResponseFormatter.php +++ b/src/web/TemplateResponseFormatter.php @@ -11,7 +11,7 @@ use craft\helpers\FileHelper; use craft\helpers\StringHelper; use craft\web\assets\iframeresizer\ContentWindowAsset; -use Twig\Error\Error as TwigError; +use Throwable; use yii\base\Component; use yii\base\ExitException; use yii\base\InvalidConfigException; @@ -50,7 +50,7 @@ public function format($response) // Render and return the template try { $response->content = $view->renderPageTemplate($behavior->template, $behavior->variables, $behavior->templateMode); - } catch (TwigError $e) { + } catch (Throwable $e) { if (!$e->getPrevious() instanceof ExitException) { // Bail on the template response $response->format = Response::FORMAT_HTML;