-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Added new ErrorController + Preview and enabling there the error renderer mechanism #33271
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
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
src/Symfony/Bundle/FrameworkBundle/Controller/ErrorController.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Controller/PreviewErrorController.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Controller/PreviewErrorController.php
Outdated
Show resolved
Hide resolved
da77722
to
f7495ec
Compare
e64481f
to
9bc74f9
Compare
src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php
Show resolved
Hide resolved
I'm introducing here a default exception controller that will use the error rendering mechanism. If you've a completely different error rendering system you'll can to replace the default controller configuring it on That possibility is available with TwigBundle installed (deprecated here), now it'll be possible with FrameworkBundle only. |
src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
26eb151
to
49b23f1
Compare
Update As there are two exception listeners when FrameworkBundle and TwigBundle are enabled, I've removed one conditionally: the This will be the migration path: twig:
- exception_controller: 'App\Controller\ExceptionController'
+ exception_controller: null
framework:
+ error_controller: 'App\Controller\ExceptionController' |
1449e0f
to
2841e59
Compare
|
@@ -27,13 +29,18 @@ public function process(ContainerBuilder $container) | |||
return; | |||
} | |||
|
|||
// register the exception controller only if Twig is enabled and required dependencies do exist | |||
if (!class_exists('Symfony\Component\ErrorRenderer\Exception\FlattenException') || !interface_exists('Symfony\Component\EventDispatcher\EventSubscriberInterface')) { |
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.
I've removed all interface_exists()
check here becase both interfaces are currently installed as hard deps.
This is ready for review! |
src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExceptionListenerPass.php
Outdated
Show resolved
Hide resolved
71d7bdd
to
5a12b6d
Compare
83755cb
to
7cce955
Compare
7cce955
to
b79532a
Compare
Thank you @yceruto. |
… the error renderer mechanism (yceruto) This PR was merged into the 4.4 branch. Discussion ---------- Added new ErrorController + Preview and enabling there the error renderer mechanism | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | yes | Tests pass? | yes (deps=high failure is normal) | Fixed tickets | - | License | MIT | Doc PR | TODO After deprecating the `ExceptionController` in TwigBundle (refs #31398) the `twig.exception_controller` config key becomes useless as feature provided by TwigBundle, while the preview controller is taking more relevance for the error renderer mechanish. **Proposal** * Deprecate the `twig.exception_controller` config key in favor of `framework.error_controller` with default `ErrorController` that activates the error renderer mechanism through the current `ExceptionListener`, meaning also that `DebugHandlersListener::onKernelException` method becomes useless too. * Deprecate the `PreviewErrorController` from TwigBundle in favor of similar in FrameworkBundle. So you no longer need to install TwigBundle to create a custom error controller or check the preview output of an error renderer (included `TwigHtmlErrorRenderer`). Btw this would fix #31398 (comment), removing here workaround in SecurityBundle. TODO: - [x] Update CHANGELOG & UPGRADE files - [x] Add tests WDYT? Commits ------- b79532a Add ErrorController to preview and render errors
@@ -27,13 +29,18 @@ public function process(ContainerBuilder $container) | |||
return; | |||
} | |||
|
|||
// register the exception controller only if Twig is enabled and required dependencies do exist | |||
if (!class_exists('Symfony\Component\ErrorRenderer\Exception\FlattenException') || !interface_exists('Symfony\Component\EventDispatcher\EventSubscriberInterface')) { | |||
// to be removed in 5.0 |
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.
@yceruto can you please send a PR on master to cleanup this?
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.
See #33476
This PR was merged into the 5.0-dev branch. Discussion ---------- [TwigBundle] Remove legacy code | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | TODO See #33271 Commits ------- abb3258 Remove legacy code
After deprecating the
ExceptionController
in TwigBundle (refs #31398) thetwig.exception_controller
config key becomes useless as feature provided by TwigBundle, while the preview controller is taking more relevance for the error renderer mechanish.Proposal
twig.exception_controller
config key in favor offramework.error_controller
with defaultErrorController
that activates the error renderer mechanism through the currentExceptionListener
, meaning also thatDebugHandlersListener::onKernelException
method becomes useless too.PreviewErrorController
from TwigBundle in favor of similar in FrameworkBundle.So you no longer need to install TwigBundle to create a custom error controller or check the preview output of an error renderer (included
TwigHtmlErrorRenderer
).Btw this would fix #31398 (comment), removing here workaround in SecurityBundle.
TODO:
WDYT?