Skip to content

Commit af86cc6

Browse files
author
Tyler Mills
authored
Ensure __toString() catches all error types
In PHP 7.1 `catch (\Exception ...)` does not catch fatal errors. Because this function can possibly throw fatal errors such as "`Call to a member function getRequestFieldName() on null`" which is an instance of `\Error`, we should catch `\Throwable` to ensure the exception makes it into the logger and `$result` is assigned the message.
1 parent 062662d commit af86cc6

File tree

1 file changed

+1
-1
lines changed
  • app/code/Magento/Ui/TemplateEngine/Xhtml

1 file changed

+1
-1
lines changed

app/code/Magento/Ui/TemplateEngine/Xhtml/Result.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function __toString()
115115
$this->compiler->compile($templateRootElement, $this->component, $this->component);
116116
$this->appendLayoutConfiguration();
117117
$result = $this->compiler->postprocessing($this->template->__toString());
118-
} catch (\Exception $e) {
118+
} catch (\Throwable $e) {
119119
$this->logger->critical($e->getMessage());
120120
$result = $e->getMessage();
121121
}

0 commit comments

Comments
 (0)