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

Tracy\IBarPanel::getTab() returning non-string breaks Tracy silently in hard to debug way #361

Closed
JanTvrdik opened this issue Apr 1, 2019 · 4 comments

Comments

@JanTvrdik
Copy link
Contributor

@JanTvrdik JanTvrdik commented Apr 1, 2019

Version: 2.6.1

Bug Description

Tracy\IBarPanel::getTab() returning non-string breaks Tracy silently in hard to debug way due to

  1. declare(strict_types=1) in bar.phtml
  2. bar.phtml uses trim() which requires string
  3. bar.phtml is rendered in a way which suppresses all errors and does not catch TypeError.

There are actually two issues:

  1. broken support for Nette\Utils\Html
  2. failing in way which makes it hard to debug.

The second one being far more important.

Steps To Reproduce

Return Nette\Utils\Html from Tracy\IBarPanel::getTab()

Expected Behavior

Tracy bar should not silently stop working without any information from user.

Possible Solution

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Apr 1, 2019

It should catch TypeError and convert them to error report in panel

tracy/src/Tracy/Bar/Bar.php

Lines 146 to 159 in 422bff7

try {
$tab = $panel->getTab();
$panelHtml = $tab ? $panel->getPanel() : null;
} catch (\Throwable $e) {
while (ob_get_level() > $obLevel) { // restore ob-level if broken
ob_end_clean();
}
$idHtml = "error-$idHtml";
$tab = "Error in $id";
$panelHtml = "<h1>Error: $id</h1><div class='tracy-inner'>" . nl2br(Helpers::escapeHtml($e)) . '</div>';
unset($e);
}
$panels[] = (object) ['id' => $idHtml, 'tab' => $tab, 'panel' => $panelHtml];

@JanTvrdik

This comment has been minimized.

Copy link
Contributor Author

@JanTvrdik JanTvrdik commented Apr 1, 2019

bar.phtml is executed outside of the try block and getTab() does not declare string return type in Tracy 2.6.1. df4d933 fixes the biggest issue.

dg added a commit that referenced this issue Apr 1, 2019
@dg dg closed this Apr 1, 2019
@JanTvrdik

This comment has been minimized.

Copy link
Contributor Author

@JanTvrdik JanTvrdik commented Apr 1, 2019

Thank you!

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Apr 1, 2019

you're welcome

dg added a commit that referenced this issue Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.