Skip to content
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

[ErrorHandler] fix handling buffered SilencedErrorContext #41760

Merged
merged 1 commit into from Jun 24, 2021

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #41745
License MIT
Doc PR -

{
if ($throwable instanceof \ErrorException) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello.
Such change (extra check for instanceof SilencedErrorContext) will lead other tools (PSR3 compatible loggers), which works with \ErrorException and don't know about Symfony to copy-paste exactly the same statement (|| $throwable instanceof SilencedErrorContext) in their implementation.

Don't you think, that make SilencedErrorContext extends \ErrorException will be better solution?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no contracts with PSR3 loggers. An entry named "exception" can hold any type.
Also, extending ErrorException would mean storing a stack trace, which is precisely the thing we want to avoid here.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After few hours I found one more place in the symfony error-handler codebase where || $ instanceof SilencedErrorContext may be missed
https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/ErrorHandler/Resources/views/logs.html.php#L20

extending ErrorException would mean storing a stack trace, which is precisely the thing we want to avoid here.

SilencedErrorContext has "lightTrace" so, as I understand the question is not in the performance (moreover $silencedErrorCache works well)

Correct me if I wrong, you don't want to storing trace only for better VarDumper usage #19568?

As I can see Symfony components designed like "independents" from each other. And this ErrorHandler so cool to be used outside of Symfony Framework (fe by people like me :) ) . I think it will be better to parametrize such tweaks (as backtrace depth) via __constructor than hardcode them for other component needs.
One more example of my words 76e7944

Let me know if the implementation of such Idea (backtrace depth) has a chance to be merged and I try my best to prepare such PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I updated the template file.
SilencedErrorContext is meant to represent silenced PHP errors.
We want it to be as light as possible, that's why they are very simple value objects and should stay as is.

@nicolas-grekas nicolas-grekas merged commit 119b3ec into symfony:4.4 Jun 24, 2021
@nicolas-grekas nicolas-grekas deleted the eh-utils branch June 28, 2021 07:38
This was referenced Jun 30, 2021
PhilETaylor pushed a commit to PhilETaylor/symfony that referenced this pull request Sep 6, 2023
…ontext (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[ErrorHandler] fix handling buffered SilencedErrorContext

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix symfony#41745
| License       | MIT
| Doc PR        | -

Commits
-------

07407c7 [ErrorHandler] fix handling buffered SilencedErrorContext
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants