Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Debug] Mimic __toString php behavior in FlattenException#28879

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromDeltachaos:flatten-trace-as-string
Mar 31, 2019

Conversation

@Deltachaos
Copy link
Contributor

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRsymfony/symfony-docs#

TheSymfony\Component\Debug\Exception\FlattenException object is returned bySymfony\Component\HttpKernel\DataCollector\ExceptionDataCollector::getException method, but the docblock of this method indicates that it should return\Exception object.

As theFlattenException class should behave as much as possible like a php\Exception object, it should implement the same methods as\Exception.

This PR is adding__toString andgetTraceAsString methods. Those methods are (in my opinion) the most useful methods of a\Exception object. A potential use case (where i am stumbled across this inconsistency) is to get the last exception of a request in aWebTestCase using the profiler and printing the trace.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedOct 15, 2018
edited
Loading

Thanks for the PR.
I think this has been rejected in the past (I'm not 100% sure though).
This can leak sensitive info to me, in case the cast is not planned.
Looks risky IMHO

@Deltachaos
Copy link
ContributorAuthor

@nicolas-grekas For the__toString() method i at least can think of situations where it can be executed accidentally when converting something to string (which is the same for other objects). But for thegetTraceAsString method it is not providing any other data that can be fetched by calling other methods of the class as well.

So i don't really see cases where this can leak sensitive data?

@DeltachaosDeltachaosforce-pushed theflatten-trace-as-string branch 6 times, most recently from3fa4f16 to0323df8CompareOctober 15, 2018 15:57
@nicolas-grekasnicolas-grekas added this to thenext milestoneOct 17, 2018
@nicolas-grekas
Copy link
Member

Fine for getTraceAsString. Do you have a use case where this would help?

@fabpot
Copy link
Member

As the FlattenException class should behave as much as possible like a php \Exception object Actually, that's never been a goal.

@Deltachaos
Copy link
ContributorAuthor

Deltachaos commentedOct 17, 2018
edited
Loading

@fabpot if this is not the goal then at least the return type declaration ofSymfony\Component\HttpKernel\DataCollector\ExceptionDataCollector::getException is not correct, as this indicates to return a\Exception but at least when using this method from aWebTestCase it returns aSymfony\Component\Debug\Exception\FlattenException.

It the behaivor wanted is thatSymfony\Component\HttpKernel\DataCollector\ExceptionDataCollector::getException should return either\Exception orSymfony\Component\Debug\Exception\FlattenException then both should implement the same interface. The commit0208800 has changed the original behaivor.

@nicolas-grekas The use case i have mentioned is to access the exception of a failed request in aWebTestCase.

@fabpot
Copy link
Member

Any news here?

@DeltachaosDeltachaosforce-pushed theflatten-trace-as-string branch 3 times, most recently from4cc7e46 toff2f7d2CompareFebruary 21, 2019 13:03
@Deltachaos
Copy link
ContributorAuthor

@fabpot have changed the method name to what@nicolas-grekas suggested. Tests have run through.

@fabpot
Copy link
Member

Thank you@Deltachaos.

@fabpotfabpot merged commit514a1b5 intosymfony:masterMar 31, 2019
fabpot added a commit that referenced this pull requestMar 31, 2019
…ion (Deltachaos)This PR was merged into the 4.3-dev branch.Discussion----------[Debug] Mimic __toString php behavior in FlattenException| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | symfony/symfony-docs#The `Symfony\Component\Debug\Exception\FlattenException` object is returned by `Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector::getException` method, but the docblock of this method indicates that it should return `\Exception` object.As the `FlattenException` class should behave as much as possible like a php `\Exception` object, it should implement the same methods as `\Exception`.This PR is adding `__toString` and `getTraceAsString` methods. Those methods are (in my opinion) the most useful methods of a `\Exception` object. A potential use case (where i am stumbled across this inconsistency) is to get the last exception of a request in a `WebTestCase` using the profiler and printing the trace.Commits-------514a1b5 [Debug] Mimic __toString php behavior in FlattenException
@nicolas-grekasnicolas-grekas modified the milestones:next,4.3Apr 30, 2019
@fabpotfabpot mentioned this pull requestMay 9, 2019
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.3

Development

Successfully merging this pull request may close these issues.

5 participants

@Deltachaos@nicolas-grekas@fabpot@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp