Skip to content

[WebProfilerBundle] Fix dump header not being displayed #48048

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

Merged
merged 1 commit into from
Dec 13, 2022

Conversation

HypeMC
Copy link
Contributor

@HypeMC HypeMC commented Oct 29, 2022

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

The bug occurs because of the following log message:

The "Symfony\Bridge\Doctrine\Logger\DbalLogger" class implements "Doctrine\DBAL\Logging\SQLLogger" that is deprecated Use {@see \Doctrine\DBAL\Logging\Middleware} or implement {@see \Doctrine\DBAL\Driver\Middleware} instead.

Since this is the first message and it contains the { character the dump header gets rendered (line 93):

public function dumpLog(Environment $env, string $message, Data $context = null)
{
$message = twig_escape_filter($env, $message);
$message = preg_replace('/&quot;(.*?)&quot;/', '&quot;<b>$1</b>&quot;', $message);
if (null === $context || !str_contains($message, '{')) {
return '<span class="dump-inline">'.$message.'</span>';
}
$replacements = [];
foreach ($context as $k => $v) {
$k = '{'.twig_escape_filter($env, $k).'}';
$replacements['&quot;<b>'.$k.'</b>&quot;'] = $replacements['&quot;'.$k.'&quot;'] = $replacements[$k] = $this->dumpData($env, $v);
}
return '<span class="dump-inline">'.strtr($message, $replacements).'</span>';
}

However, since there is no actual placeholder to replace, the header is never displayed, but is marked as displayed and never rendered again:

protected function getDumpHeader()
{
$this->headerIsDumped = $this->outputStream ?? $this->lineDumper;

protected function dumpLine(int $depth, bool $endOfValue = false)
{
if (-1 === $this->lastDepth) {
$this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
}
if ($this->headerIsDumped !== ($this->outputStream ?? $this->lineDumper)) {
$this->line = $this->getDumpHeader().$this->line;
}

With this PR, the WebProfilerExtension::dumpLog() method will check the message for exact placeholders.

@carsonbot carsonbot added this to the 5.4 milestone Oct 29, 2022
@HypeMC HypeMC force-pushed the profiler-dump-header branch from 6668bd3 to 2f2d6d3 Compare October 29, 2022 16:40
@HypeMC HypeMC changed the base branch from 5.4 to 4.4 October 29, 2022 16:41
@HypeMC HypeMC force-pushed the profiler-dump-header branch from 2f2d6d3 to 21f3389 Compare October 29, 2022 16:44
@PhilETaylor
Copy link
Contributor

I have tested this and it fixes the JS issue reported perfectly. Thanks.

However, probably unrelated, there is another bug I see - watch:

Screen.Recording.2022-10-30.at.11.49.09.mov

@HypeMC
Copy link
Contributor Author

HypeMC commented Oct 30, 2022

I have tested this and it fixes the JS issue reported perfectly. Thanks.

However, probably unrelated, there is another bug I see - watch:

Screen.Recording.2022-10-30.at.11.49.09.mov

@PhilETaylor Hi, thanks for the feedback. Unfortunately I'm unable to view your video on my computer (probably cause I'm on linux), is there any chance you could describe the issue or send some screenshots or gifs or something?

@PhilETaylor
Copy link
Contributor

Sorry, here it is at Youtube so you should be able to view that right https://youtu.be/h5ztf03Zhjw ? The bug is at 7 seconds in when clicking the > next to the foreach loop, which, instead of collapsing the foreach loop next to the > goes on to close an unrelated dump in the trace.

@HypeMC
Copy link
Contributor Author

HypeMC commented Oct 31, 2022

Sorry, here it is at Youtube so you should be able to view that right https://youtu.be/h5ztf03Zhjw ? The bug is at 7 seconds in when clicking the > next to the foreach loop, which, instead of collapsing the foreach loop next to the > goes on to close an unrelated dump in the trace.

@PhilETaylor This looks like a javascript issue. I think it was introduced in #33486, but I'd have to look into it a little deeper. In any case, it's not related to this issue.

@HypeMC HypeMC changed the base branch from 4.4 to 5.4 November 28, 2022 19:43
@nicolas-grekas
Copy link
Member

Oops, can you please have a look at failures on deps=low?

@HypeMC HypeMC force-pushed the profiler-dump-header branch 2 times, most recently from 7094692 to 68dc72d Compare December 13, 2022 11:35
@HypeMC
Copy link
Contributor Author

HypeMC commented Dec 13, 2022

@nicolas-grekas Sorry about that, must've missed that one, should be good now 68dc72d . I've also rebased the branch since it was originally intended for 4.4.

@nicolas-grekas
Copy link
Member

Thank you @HypeMC.

@nicolas-grekas nicolas-grekas merged commit af562a7 into symfony:5.4 Dec 13, 2022
@HypeMC HypeMC deleted the profiler-dump-header branch December 13, 2022 13:16
@fabpot fabpot mentioned this pull request Dec 16, 2022
This was referenced Dec 28, 2022
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.

4 participants