-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[ErrorHandler] Allow override of the default non-debug template #37492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php
Outdated
Show resolved
Hide resolved
ready for review again :-) Thx. Any idea how long 5.2.0 release will take? Just so we can plan for the integration with the Joomla 4 release that's in development, need to see if the work needed to translate/customise the Joomla error page - which relies on this PR - is worth doing for the Joomla 4 release or waiting for Joomla 4.1 - Thanks again,. |
About the release of 5.2 this will be out in November 2020 (https://symfony.com/releases/5.2) |
I have allowed a relative or absolute path to custom non-debug template with another light touch, simply checking if the file exists, this then has no knock on effects when used in a full Symfony stack or when no custom template is set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Awesome - thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (minor comment)
src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php
Outdated
Show resolved
Hide resolved
Thank you @PhilETaylor. |
@fabpot Can you merge this PR also to 4.4 ? |
…r (stlrnz) This PR was submitted for the 5.x branch but it was merged into the 5.2 branch instead. Discussion ---------- [ErrorHandler] Fix error caused by `include` + open_basedir | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | | License | MIT | Doc PR | #37492 introduced the option to specify your own error template using `HtmlErrorRenderer::setTemplate('...');` However, the implementation using `file_exists(...)` in `include` can cause an error when not setting a custom template. > php.WARNING: Warning: file_exists(): open_basedir restriction in effect. File(assets/css/error.css) is not within the allowed path(s): (...) {"exception":"[object] (ErrorException(code: 0): Warning: file_exists(): open_basedir restriction in effect. File(assets/css/error.css) is not within the allowed path(s): (...) at ...\\vendor\\symfony\\error-handler\\ErrorRenderer\\HtmlErrorRenderer.php:355)"} [] As you can see the error is caused by checking `file_exists(...)` using relative paths in environments with a restrictive `open_basedir` policy. The proposed solution always uses absolute paths to include errors templates (and other files). Commits ------- 9ad7832 [ErrorHandler] Fix error caused by `include` + open_basedir
Add new feature to allow the default hardcoded non-debug template to be overridden when
symfony/error-handler
used as a component in other projects.Currently, when used as a component, its not possible (that I could see) to override the standard default template of
views/error.html.php
therefore the look and feel, and text is hard coded. There is much written on how to customise the error pages when using the full symfony stack, but not when using individualsymfony/error-handler
component on its own.This PR is related to the use of
symfony/error-handler
as a component in other projects - specifically the Joomla Content Management System, where, in non debug mode, a generic template needs to be translatable, and customisable even though most of the time when the error occurs will be at boot time and not much available to it. joomla/joomla-cms#29968This PR allows the use of code such as
and then for further customisation of the "look and feel" to be done in
mine.php
Due to the unique way the error handler component is init'ed, the use of static calls has been employed rather than any DI approach, I hope this is ok.