Skip to content

Commit 338f75b

Browse files
committed
Update Tracy core
1 parent d4aad96 commit 338f75b

40 files changed

+409
-389
lines changed

TracyDebugger.module.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public static function getModuleInfo() {
2727
'summary' => __('Tracy debugger from Nette with many PW specific custom tools.', __FILE__),
2828
'author' => 'Adrian Jones',
2929
'href' => 'https://processwire.com/talk/forum/58-tracy-debugger/',
30-
'version' => '4.27.5',
30+
'version' => '4.27.6',
3131
'autoload' => 100000, // in PW 3.0.114+ higher numbers are loaded first - we want Tracy first
3232
'singular' => true,
3333
'requires' => 'ProcessWire>=2.7.2, PHP>=5.4.4',
@@ -2669,6 +2669,9 @@ private function getallheaders() {
26692669
* PUBLIC STATIC HELPER FUNCTIONS
26702670
*/
26712671

2672+
public static function isAjax() {
2673+
return isset($_SERVER['HTTP_X_TRACY_AJAX']) && preg_match('#^\w{10,15}$#D', $_SERVER['HTTP_X_TRACY_AJAX']);
2674+
}
26722675

26732676
/**
26742677
* is the provided string a valid json string?
@@ -2898,8 +2901,8 @@ public static function getDataValue($property) {
28982901
*/
28992902
public static function isAdditionalBar() {
29002903
$isRedirect = preg_match('#^Location:#im', implode("\n", headers_list()));
2901-
if(Helpers::isAjax() || $isRedirect) {
2902-
return Helpers::isAjax() ? 'ajax' : 'redirect';
2904+
if(static::isAjax() || $isRedirect) {
2905+
return static::isAjax() ? 'ajax' : 'redirect';
29032906
}
29042907
else {
29052908
return false;

tracy-2.11.x/composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"nette/tester": "^2.6",
2828
"latte/latte": "^2.5 || ^3.0",
2929
"psr/log": "^1.0 || ^2.0 || ^3.0",
30-
"phpstan/phpstan": "^2.0@stable"
30+
"phpstan/phpstan": "^2.1@stable",
31+
"phpstan/extension-installer": "^1.4@stable",
32+
"nette/phpstan-rules": "^1.0"
3133
},
3234
"conflict": {
3335
"nette/di": "<3.0"
@@ -48,5 +50,10 @@
4850
"branch-alias": {
4951
"dev-master": "2.11-dev"
5052
}
53+
},
54+
"config": {
55+
"allow-plugins": {
56+
"phpstan/extension-installer": true
57+
}
5158
}
5259
}

tracy-2.11.x/src/Bridges/Nette/Bridge.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,12 @@ public static function renderMemberAccessException(?\Throwable $e): ?array
4646

4747
$loc = Tracy\Debugger::mapSource($loc['file'], $loc['line']) ?? $loc;
4848
if (preg_match('#Cannot (?:read|write to) an undeclared property .+::\$(\w+), did you mean \$(\w+)\?#A', $e->getMessage(), $m)) {
49-
return [
50-
'link' => Helpers::editorUri($loc['file'], $loc['line'], 'fix', '->' . $m[1], '->' . $m[2]),
51-
'label' => 'fix it',
52-
];
49+
$link = Helpers::editorUri($loc['file'], $loc['line'], 'fix', '->' . $m[1], '->' . $m[2]);
50+
return $link !== null ? ['link' => $link, 'label' => 'fix it'] : null;
5351
} elseif (preg_match('#Call to undefined (static )?method .+::(\w+)\(\), did you mean (\w+)\(\)?#A', $e->getMessage(), $m)) {
5452
$operator = $m[1] ? '::' : '->';
55-
return [
56-
'link' => Helpers::editorUri($loc['file'], $loc['line'], 'fix', $operator . $m[2] . '(', $operator . $m[3] . '('),
57-
'label' => 'fix it',
58-
];
53+
$link = Helpers::editorUri($loc['file'], $loc['line'], 'fix', $operator . $m[2] . '(', $operator . $m[3] . '(');
54+
return $link !== null ? ['link' => $link, 'label' => 'fix it'] : null;
5955
}
6056

6157
return null;

tracy-2.11.x/src/Bridges/Nette/TracyExtension.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class): void
182182
private function parseErrorSeverity(string|array $value): int
183183
{
184184
$value = implode('|', (array) $value);
185-
$res = (int) @parse_ini_string('e = ' . $value)['e']; // @ may fail
185+
$ini = @parse_ini_string('e = ' . $value); // @ may fail
186+
$res = (int) ($ini['e'] ?? 0);
186187
if (!$res) {
187188
throw new Nette\InvalidStateException("Syntax error in expression '$value'");
188189
}

tracy-2.11.x/src/Tracy/Bar/Bar.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ public function renderLoader(DeferredContent $defer): void
6060

6161
$this->loaderRendered = true;
6262
$requestId = $defer->getRequestId();
63-
$nonceAttr = Helpers::getNonceAttr();
6463
$async = true;
65-
require __DIR__ . '/assets/loader.phtml';
64+
require __DIR__ . '/dist/loader.phtml';
6665
}
6766

6867

@@ -74,7 +73,7 @@ public function render(DeferredContent $defer): void
7473
$redirectQueue = &$defer->getItems('redirect');
7574
$requestId = $defer->getRequestId();
7675

77-
if (Helpers::isAjax()) {
76+
if ($defer->isDeferred()) {
7877
if ($defer->isAvailable()) {
7978
$defer->addSetup('Tracy.Debug.loadAjax', $this->renderPartial('ajax', '-ajax:' . $requestId));
8079
}
@@ -102,10 +101,9 @@ public function render(DeferredContent $defer): void
102101
$defer->addSetup('Tracy.Debug.init', $content);
103102

104103
} else {
105-
$nonceAttr = Helpers::getNonceAttr();
106104
$async = false;
107105
Debugger::removeOutputBuffers(errorOccurred: false);
108-
require __DIR__ . '/assets/loader.phtml';
106+
require __DIR__ . '/dist/loader.phtml';
109107
}
110108
}
111109
}
@@ -118,16 +116,16 @@ private function renderPartial(string $type, string $suffix = ''): array
118116

119117
return [
120118
'bar' => Helpers::capture(function () use ($type, $panels) {
121-
require __DIR__ . '/assets/bar.phtml';
119+
require __DIR__ . '/dist/bar.phtml';
122120
}),
123121
'panels' => Helpers::capture(function () use ($type, $panels) {
124-
require __DIR__ . '/assets/panels.phtml';
122+
require __DIR__ . '/dist/panels.phtml';
125123
}),
126124
];
127125
}
128126

129127

130-
/** @return \stdClass[] */
128+
/** @return list<\stdClass> */
131129
private function renderPanels(string $suffix = ''): array
132130
{
133131
set_error_handler(function (int $severity, string $message, string $file, int $line): bool {

tracy-2.11.x/src/Tracy/Bar/DefaultBarPanel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getTab(): string
3333
{
3434
return Helpers::capture(function () {
3535
$data = $this->data;
36-
require __DIR__ . "/panels/{$this->id}.tab.phtml";
36+
require __DIR__ . "/dist/{$this->id}.tab.phtml";
3737
});
3838
}
3939

@@ -44,9 +44,9 @@ public function getTab(): string
4444
public function getPanel(): string
4545
{
4646
return Helpers::capture(function () {
47-
if (is_file(__DIR__ . "/panels/{$this->id}.panel.phtml")) {
47+
if (is_file(__DIR__ . "/dist/{$this->id}.panel.phtml")) {
4848
$data = $this->data;
49-
require __DIR__ . "/panels/{$this->id}.panel.phtml";
49+
require __DIR__ . "/dist/{$this->id}.panel.phtml";
5050
}
5151
});
5252
}

tracy-2.11.x/src/Tracy/Bar/IBarPanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ interface IBarPanel
1717
{
1818
/**
1919
* Renders HTML code for custom tab.
20-
* @return string
20+
* @return ?string
2121
*/
2222
function getTab();
2323

2424
/**
2525
* Renders HTML code for custom panel.
26-
* @return string
26+
* @return ?string
2727
*/
2828
function getPanel();
2929
}

tracy-2.11.x/src/Tracy/Bar/assets/bar.phtml

Lines changed: 0 additions & 31 deletions
This file was deleted.

tracy-2.11.x/src/Tracy/Bar/assets/loader.phtml

Lines changed: 0 additions & 29 deletions
This file was deleted.

tracy-2.11.x/src/Tracy/Bar/assets/panels.phtml

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)