-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
return stream_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
@wouterj Looks really interesting. Would it be possible to try to keep the same vertical height as before? |
$this->dumper->setOutput($prevOutput); | ||
rewind($dump); | ||
|
||
return stream_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
@@ -14,7 +14,7 @@ | |||
/** | |||
* @author Nicolas Grekas <p@tchwork.com> | |||
*/ | |||
class Data | |||
class Data implements \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.
8010483
to
6e092ef
Compare
I don't understand the PHP 7.1 failures. |
If anything helps "A non well formed numeric value encountered" is a common data conversion error str to time or number format. |
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFunctions() | ||
{ | ||
return array( | ||
new \Twig_SimpleFunction('profiler_dump', array($this, 'dumpValue')), | ||
new \Twig_SimpleFunction('profiler_dump', array($this, 'dumpValue'), array('is_safe' => array('html'))), |
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?
See suggestions as patch directly in nicolas-grekas#6 |
6e092ef
to
e6cc848
Compare
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. |
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! |
@weaverryan I've now collapsed all dumps by default (and expanded the first level for the log context). Also tried to fix the tests. |
New suggestions in the latest commit of nicolas-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#6891 ping @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
PR rebased in my fork to benefit from latest VarDumper features. Don't forget to set |
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? |
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? |
06d75a7
to
9ec1d88
Compare
@@ -11,10 +11,15 @@ | |||
|
|||
namespace Symfony\Component\Form\Extension\DataCollector; | |||
|
|||
use Symfony\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
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
to
a6774cb
Compare
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). |
a6774cb
to
fa41e63
Compare
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. |
Two glitches:
|
fa41e63
to
eddecbd
Compare
thanks, applied the changes |
👍 |
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 profiler 41a7649 [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/A Was missed in #19614 ? ### Before  ### After  Commits ------- 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/A Was missed in symfony#19614 ? ### Before  ### After  Commits ------- 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
Data
class of VarDumper is made serializable, to reduce the size of the stored profiler data.Screenshots
Further Improvements