Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpKernel] Use VarDumper in the profiler#19614
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| returnstream_get_contents($dump); | ||
| } | ||
| @trigger_error('Dumping non-cloned data is deprecated since version 3.2 and will be removed in 4.0. Use DataCollector::cloneVar().',E_USER_DEPRECATED); |
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.
not sure if this makes sense:
- Strings are still perfectly fine
- Deprecations aren't shown, as profiler pages aren't data-collected afaik
fabpot commentedAug 14, 2016
@wouterj Looks really interesting. Would it be possible to try to keep the same vertical height as before? |
| $this->dumper->setOutput($prevOutput); | ||
| rewind($dump); | ||
| returnstream_get_contents($dump); |
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.
@nicolas-grekas is it possible provide more convenient api for getting dumped content?
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.
Proposed a way to do this:#19616
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.
This snippet can be reduced to three lines by using the second arg of the dump method and the third of steam_get_contents
Koc commentedAug 14, 2016
wouterj commentedAug 14, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
| * @author Nicolas Grekas <p@tchwork.com> | ||
| */ | ||
| class Data | ||
| class Dataimplements \Serializable |
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.
Is it need? I don't get why, can't the object be serialized without implementing 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.
@wouterj can you show before/after content of serialized object? Looks like you pass all of the properties to serialize, does it some changes?
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.
reverted this change, it was also causing build errors.
wouterj commentedAug 15, 2016
I don't understand the PHP 7.1 failures. |
yceruto commentedAug 15, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
If anything helps"A non well formed numeric value encountered" is a common data conversion error str to time or number format. |
| { | ||
| returnarray( | ||
| new \Twig_SimpleFunction('profiler_dump',array($this,'dumpValue')), | ||
| new \Twig_SimpleFunction('profiler_dump',array($this,'dumpValue'),array('is_safe' =>array('html'))), |
nicolas-grekasAug 16, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
This looks dangerous to me: the legacy implementation is still in use, but it's now considered "html-safe".
What about using a new function instead?
nicolas-grekas commentedAug 17, 2016
See suggestions as patch directly innicolas-grekas#6 |
wouterj commentedAug 17, 2016
Thanks@nicolas-grekas for your patch! I've cherry-picked it into this PR and tried to fix the LoggerDataCollector (not sure if this is what was expected though, will test later this week in a Symfony app). I hope the PHP 7.1 test failure is suddently fixed as well. I've tested it using PHP 7.1.0-beta2 on my local PC and don't get the error. |
weaverryan commentedAug 17, 2016
This is great! Is it possible in the component to have the objects dumped in a non-expanded state by default? I was thinking that for things like your contentDocument, it pushes the other content far down on the initial load of the page. Thanks! |
wouterj commentedAug 17, 2016
@weaverryan I've now collapsed all dumps by default (and expanded the first level for the log context). Also tried to fix the tests. |
nicolas-grekas commentedAug 18, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
New suggestions inthe latest commit ofnicolas-grekas#6 (needs#19656 to be at its best):
|
…ctures (nicolas-grekas)This PR was merged into the 3.2-dev branch.Discussion----------[VarDumper] Allow dumping subparts of cloned Data structures| Q | A| ------------- | ---| Branch? | master| New feature? | yes| Tests pass? | yes| License | MIT| Doc PR |symfony/symfony-docs#6891ping@wouterj: with this, we'll be able to dump only the trace for deprecations in#19614 instead of being forced to dump the full exception right now. See test case.We'd do `{{ profiler_dump(log.context.seek('trace')) }}` in `logger.html.twig`.Commits-------8f2f440 [VarDumper] Allow dumping subparts of cloned Data structures
nicolas-grekas commentedAug 19, 2016
PR rebased in my fork to benefit from latest VarDumper features. Don't forget to set |
wouterj commentedAug 20, 2016
Discovered a problem with this implementation (with all latest work by@nicolas-grekas): The logger panel is now completely unresponsive in the CMF sandbox (it has 251 debug messages with context that includes a Doctrine mapped document). Is there anyway to work around this? |
nicolas-grekas commentedAug 20, 2016
That's one of the reasons why I think this needs more work :) The dumps integration is a bit rough right now, but there is no issue with the base implementation, only more CSS to write and a few JS to fine tune the US. What about adding back the show/hide context button? |
| namespaceSymfony\Component\Form\Extension\DataCollector; | ||
| useSymfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface; |
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.
useless as it is already in the same namespace
stof commentedAug 26, 2016
The serialized data is fine. We never guaranteed BC on the storage format of the profiler between minor versions (i.e. you cannot load a profile generated with X.Y in a X.Z runtime, you have to clear your profile storage when upgrading, which is done by default as they are stored in the cache). regarding the DebugAccessDecisionManager and the FormDataExtractor, I think it is fine, as they are mostly meant to be consumed by the profiler collectors. |
693386d toa6774cbComparefabpot commentedSep 14, 2016
what's the status of this PR? I would really like to be able to merge it in time for 3.2 (end of dev by the end of the month). |
wouterj commentedSep 17, 2016
With the great help of@nicolas-grekas, I think this PR is now finished and ready for review. I've just tested all changed profiler panels and fixed some small rendering issues. |
nicolas-grekas commentedSep 17, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Two glitches:
|
wouterj commentedSep 17, 2016
thanks, applied the changes |
nicolas-grekas commentedSep 17, 2016
👍 |
fabpot commentedSep 17, 2016
Thank you@wouterj. |
…icolas-grekas)This PR was merged into the 3.2-dev branch.Discussion----------[HttpKernel] Use VarDumper in the profiler| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | yes| Tests pass? | yes| Fixed tickets | part of#18149| License | MIT| Doc PR | -/cc@javiereguiluz@nicolas-grekas As you're the main maintainers of the changed features.Summary--- * The `varToString()` method is deprecated in favor of `cloneVar()` (using the VarCloner) and `dump()` (using the VarDumper). This allows to show more detailed and better formatted data in the profiler. * The `Data` class of VarDumper is made serializable, to reduce the size of the stored profiler data.Screenshots---Further Improvements--- * Change the dump colors (I've now implemented a very basic light theme, but my colorskills are close to zero, so a proper designer should look at it)Commits-------eddecbd [HttpKernel] Use VarDumper in the Logs&Events panels of the profiler41a7649 [HttpKernel] Use VarDumper in the profiler
…or should use cloneVar (ogizanagi)This PR was merged into the 3.2 branch.Discussion----------[WebProfilerBundle][Translator] Fix TranslationDataCollector should use cloneVar| Q | A| ------------- | ---| Branch? | 3.2| Bug fix? | yes?| New feature? | no?| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | N/A| License | MIT| Doc PR | N/AWas missed in#19614 ?### Before### AfterCommits-------07cdfd5 [WebProfiler][Translator] Fix TranslationDataCollector should use cloneVar
…Collector should use cloneVar (ogizanagi)This PR was merged into the 3.2 branch.Discussion----------[WebProfilerBundle][Translator] Fix TranslationDataCollector should use cloneVar| Q | A| ------------- | ---| Branch? | 3.2| Bug fix? | yes?| New feature? | no?| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | N/A| License | MIT| Doc PR | N/AWas missed insymfony#19614 ?### Before### AfterCommits-------07cdfd5 [WebProfiler][Translator] Fix TranslationDataCollector should use cloneVar

/cc@javiereguiluz@nicolas-grekas As you're the main maintainers of the changed features.
Summary
The
varToString()method is deprecated in favor ofcloneVar()(using the VarCloner) anddump()(using the VarDumper).This allows to show more detailed and better formatted data in the profiler.
The
Dataclass of VarDumper is made serializable, to reduce the size of the stored profiler data.Screenshots
Further Improvements