Skip to content

Commit

Permalink
Update Tracy core
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbj committed Apr 29, 2024
1 parent fe93c5f commit 61bed50
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 32 deletions.
4 changes: 2 additions & 2 deletions TracyDebugger.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function getModuleInfo() {
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
'author' => 'Adrian Jones',
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
'version' => '4.26.23',
'version' => '4.26.24',
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
'singular' => true,
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
Expand Down Expand Up @@ -1179,7 +1179,7 @@ function hideDebugBar() {
$nonWire = false;
$nonDeprecations = false;
foreach($tracyErrors->data as $tracyError => $count) {
if(strpos($tracyError, 'PHP Deprecated:') === false) {
if(strpos($tracyError, 'Deprecated:') === false) {
$nonDeprecations = true;
break;
}
Expand Down
3 changes: 1 addition & 2 deletions tracy-2.10.x/src/Tracy/Bar/panels/errors.panel.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ namespace Tracy;

/** @var int[] $data */
?>
<h1>Errors</h1>
<h1>Warnings</h1>

<div class="tracy-inner">
<table class="tracy-sortable">
<tr><th>Count</th><th>Error</th></tr>
<?php foreach ($data as $item => $count): [$file, $line, $message] = explode('|', $item, 3) ?>
<tr>
<td class="tracy-right"><?= $count ? "$count\xC3\x97" : '' ?></td>
Expand Down
2 changes: 1 addition & 1 deletion tracy-2.10.x/src/Tracy/Bar/panels/errors.tab.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ if (empty($data)) {
</style>
<span class="tracy-ErrorTab">
<svg viewBox="0 0 2048 2048"><path fill="#fff" d="M1152 1503v-190q0-14-9.5-23.5t-22.5-9.5h-192q-13 0-22.5 9.5t-9.5 23.5v190q0 14 9.5 23.5t22.5 9.5h192q13 0 22.5-9.5t9.5-23.5zm-2-374l18-459q0-12-10-19-13-11-24-11h-220q-11 0-24 11-10 7-10 21l17 457q0 10 10 16.5t24 6.5h185q14 0 23.5-6.5t10.5-16.5zm-14-934l768 1408q35 63-2 126-17 29-46.5 46t-63.5 17h-1536q-34 0-63.5-17t-46.5-46q-37-63-2-126l768-1408q17-31 47-49t65-18 65 18 47 49z"/>
</svg><span class="tracy-label"><?= $sum = array_sum($data), $sum > 1 ? ' errors' : ' error' ?></span>
</svg><span class="tracy-label"><?= $sum = array_sum($data), $sum > 1 ? ' warnings' : ' warning' ?></span>
</span>
2 changes: 1 addition & 1 deletion tracy-2.10.x/src/Tracy/BlueScreen/BlueScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private function renderActions(\Throwable $ex): array
$actions[] = $ex->tracyAction;
}

if (preg_match('# ([\'"])(\w{3,}(?:\\\\\w{3,})+)\1#i', $ex->getMessage(), $m)) {
if (preg_match('# ([\'"])(\w{3,}(?:\\\\\w{2,})+)\1#i', $ex->getMessage(), $m)) {
$class = $m[2];
if (
!class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false)
Expand Down
43 changes: 38 additions & 5 deletions tracy-2.10.x/src/Tracy/BlueScreen/assets/section-http.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,53 @@ if (Helpers::isCli()) {
<?php endif ?>


<?php foreach (['_GET', '_POST', '_COOKIE'] as $name): ?>
<h3>$<?= Helpers::escapeHtml($name) ?></h3>
<?php if (empty($GLOBALS[$name])):?>
<h3>$_GET</h3>
<?php if (empty($_GET)):?>
<p><i>empty</i></p>
<?php else: ?>
<div class="tracy-pane">
<table class="tracy-sortable">
<?php foreach ($GLOBALS[$name] as $k => $v): ?>
<?php foreach ($_GET as $k => $v): ?>
<tr><th><?= Helpers::escapeHtml($k) ?></th><td><?= $dump($v, $k) ?></td></tr>
<?php endforeach ?>
</table>
</div>
<?php endif ?>


<?php if ($_SERVER['REQUEST_METHOD'] ?? null === 'POST'):?>
<?php if (empty($_POST)):?>
<?php if (($post = file_get_contents('php://input', length: 2000)) === ''): ?>
<h3>$_POST</h3>
<p><i>empty</i></p>
<?php else: ?>
<h3>POST (preview)</h3>
<?= $dump($post) ?>
<?php endif ?>
<?php else: ?>
<h3>$_POST</h3>
<div class="tracy-pane">
<table class="tracy-sortable">
<?php foreach ($_POST as $k => $v): ?>
<tr><th><?= Helpers::escapeHtml($k) ?></th><td><?= $dump($v, $k) ?></td></tr>
<?php endforeach ?>
</table>
</div>
<?php endif ?>
<?php endif ?>

<h3>$_COOKIE</h3>
<?php if (empty($_COOKIE)):?>
<p><i>empty</i></p>
<?php else: ?>
<div class="tracy-pane">
<table class="tracy-sortable">
<?php foreach ($_COOKIE as $k => $v): ?>
<tr><th><?= Helpers::escapeHtml($k) ?></th><td><?= $dump($v, $k) ?></td></tr>
<?php endforeach ?>
</table>
</div>
<?php endif ?>
<?php endforeach ?>
</div>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ namespace Tracy;
*/

$stack = $ex->getTrace();
if (in_array($stack[0]['class'] ?? null, [DevelopmentStrategy::class, ProductionStrategy::class], true)) {
array_shift($stack);
}
if (($stack[0]['class'] ?? null) === Debugger::class && in_array($stack[0]['function'], ['shutdownHandler', 'errorHandler'], true)) {
array_shift($stack);
}

$expanded = null;
if (
(!$ex instanceof \ErrorException
|| in_array($ex->getSeverity(), [E_USER_NOTICE, E_USER_WARNING, E_USER_DEPRECATED], true))
(!$ex instanceof \ErrorException || in_array($ex->getSeverity(), [E_USER_NOTICE, E_USER_WARNING, E_USER_DEPRECATED], true))
&& $this->isCollapsed($ex->getFile())
) {
foreach ($stack as $key => $row) {
Expand All @@ -25,12 +31,6 @@ if (
}
}

if (in_array($stack[0]['class'] ?? null, [DevelopmentStrategy::class, ProductionStrategy::class], true)) {
array_shift($stack);
}
if (($stack[0]['class'] ?? null) === Debugger::class && in_array($stack[0]['function'], ['shutdownHandler', 'errorHandler'], true)) {
array_shift($stack);
}
$file = $ex->getFile();
$line = $ex->getLine();

Expand Down
19 changes: 7 additions & 12 deletions tracy-2.10.x/src/Tracy/Debugger/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class Debugger
{
public const Version = '2.10.6';
public const Version = '2.10.7';

/** server modes for Debugger::enable() */
public const
Expand Down Expand Up @@ -194,19 +194,14 @@ public static function enable(
: !self::detectDebugMode($mode);
}

self::$reserved = str_repeat('t', self::$reservedMemorySize);
self::$time = $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true);
self::$obLevel = ob_get_level();
self::$cpuUsage = !self::$productionMode && function_exists('getrusage') ? getrusage() : null;
self::$reserved ??= str_repeat('t', self::$reservedMemorySize);
self::$time ??= $_SERVER['REQUEST_TIME_FLOAT'] ?? microtime(true);
self::$obLevel ??= ob_get_level();
self::$cpuUsage ??= !self::$productionMode && function_exists('getrusage') ? getrusage() : null;

// logging configuration
if ($email !== null) {
self::$email = $email;
}

if ($logDirectory !== null) {
self::$logDirectory = $logDirectory;
}
self::$email = $email ?? self::$email;
self::$logDirectory = $logDirectory ?? self::$logDirectory;

if (self::$logDirectory) {
if (!preg_match('#([a-z]+:)?[/\\\\]#Ai', self::$logDirectory)) {
Expand Down
2 changes: 1 addition & 1 deletion tracy-2.10.x/src/Tracy/Debugger/DevelopmentStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function handleError(
exit(255);
}

$message = 'PHP ' . Helpers::errorTypeToString($severity) . ': ' . Helpers::improveError($message);
$message = Helpers::errorTypeToString($severity) . ': ' . Helpers::improveError($message);
$count = &$this->bar->getPanel('Tracy:errors')->data["$file|$line|$message"];

if (!$count++ && !Helpers::isHtmlMode() && !Helpers::isAjax()) {
Expand Down

0 comments on commit 61bed50

Please sign in to comment.