Skip to content

Commit

Permalink
Update Tracy core
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbj committed Nov 7, 2024
1 parent 5c48591 commit bf7603c
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 30 deletions.
2 changes: 1 addition & 1 deletion 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.41',
'version' => '4.26.42',
'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
1 change: 1 addition & 0 deletions includes/GetPageById.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$pageInfo['url'] = $p->url;
$pageInfo['template_id'] = $p->template->id;
$pageInfo['template_name'] = $p->template->name;
$pageInfo['template_label'] = $p->template->label;
$pageInfo['path'] = $p->path;
$pageInfo['unpublished'] = $p->isUnpublished();
$pageInfo['hidden'] = $p->isHidden();
Expand Down
2 changes: 1 addition & 1 deletion panels/ProcesswireInfoPanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function tracyClearGoToPageID(matchStatus) {
if(xmlhttp.status == 200 && xmlhttp.responseText !== "[]") {
var pageDetails = JSON.parse(xmlhttp.responseText);
console.log(pageDetails.trash);
document.getElementById("pageDetails").innerHTML = "<span uk-tooltip title='" + pageDetails.path + "' style='" + (pageDetails.unpublished ? 'text-decoration: line-through' : '') + (pageDetails.hidden ? '; opacity: 0.5' : '') + "'>" + (pageDetails.trash ? '🗑︎ ' : '') + pageDetails.title + "</span>&nbsp;(<a href='{$this->wire('config')->urls->admin}setup/template/edit?id=" + pageDetails.template_id + "' style='color:#888'>" + pageDetails.template_name + "</a>)";
document.getElementById("pageDetails").innerHTML = "<span uk-tooltip title='" + pageDetails.path + "' style='" + (pageDetails.unpublished ? 'text-decoration: line-through' : '') + (pageDetails.hidden ? '; opacity: 0.5' : '') + "'>" + (pageDetails.trash ? '🗑︎ ' : '') + pageDetails.title + "</span>&nbsp;(<a href='{$this->wire('config')->urls->admin}setup/template/edit?id=" + pageDetails.template_id + "' style='color:#888' title='" + (pageDetails.template_label ? pageDetails.template_label : '') + "' uk-tooltip>" + pageDetails.template_name + "</a>)";
document.getElementById("idGoToEdit").href = "{$this->wire('config')->urls->admin}page/edit/?id=" + pageDetails.id;
document.getElementById("idGoToView").href = pageDetails.url;
document.getElementById("idGoToOpen").href = "{$this->wire('config')->urls->admin}page/?open=" + pageDetails.id;
Expand Down
4 changes: 2 additions & 2 deletions tracy-2.10.x/src/Tracy/Bar/assets/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ class Panel {

let doc = win.document;
doc.write('<!DOCTYPE html><meta charset="utf-8">'
+ '<script src="' + (baseUrl.replace(/&/g, '&amp;').replace(/"/g, '&quot;')) + '_tracy_bar=js&amp;XDEBUG_SESSION_STOP=1" onload="Tracy.Dumper.init()" async></script>'
+ '<body id="tracy-debug">',
+ '<script src="' + (baseUrl.replace(/&/g, '&amp;').replace(/"/g, '&quot;')) + '_tracy_bar=js&amp;XDEBUG_SESSION_STOP=1" onload="Tracy.Dumper.init()" async></script>'
+ '<body id="tracy-debug">',
);

let meta = this.elem.parentElement.lastElementChild;
Expand Down
1 change: 1 addition & 0 deletions tracy-2.10.x/src/Tracy/BlueScreen/assets/page.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ array_map(function ($file) { echo '(function(){', str_replace(['<!--', '</s'], [
__DIR__ . '/../../assets/toggle.js',
__DIR__ . '/../../assets/table-sort.js',
__DIR__ . '/../../assets/tabs.js',
__DIR__ . '/../../assets/helpers.js',
__DIR__ . '/../../Dumper/assets/dumper.js',
__DIR__ . '/bluescreen.js',
]);
Expand Down
2 changes: 1 addition & 1 deletion 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.8';
public const Version = '2.10.9';

/** server modes for Debugger::enable() */
public const
Expand Down
1 change: 1 addition & 0 deletions tracy-2.10.x/src/Tracy/Debugger/DeferredContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private function buildJsCss(): string
__DIR__ . '/../assets/toggle.js',
__DIR__ . '/../assets/table-sort.js',
__DIR__ . '/../assets/tabs.js',
__DIR__ . '/../assets/helpers.js',
__DIR__ . '/../Dumper/assets/dumper.js',
__DIR__ . '/../BlueScreen/assets/bluescreen.js',
]);
Expand Down
11 changes: 6 additions & 5 deletions tracy-2.10.x/src/Tracy/Debugger/assets/error.500.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ namespace Tracy;
<title>Server Error</title>

<style>
#tracy-error { all: initial; position: absolute; top: 0; left: 0; right: 0; height: 70vh; min-height: 400px; display: flex; align-items: center; justify-content: center; z-index: 1000 }
#tracy-error div { all: initial; max-width: 550px; background: white; color: #333; display: block }
#tracy-error h1 { all: initial; font: bold 50px/1.1 sans-serif; display: block; margin: 40px }
#tracy-error p { all: initial; font: 20px/1.4 sans-serif; margin: 40px; display: block }
#tracy-error small { color: gray }
#tracy-error { all: initial; position: absolute; top: 0; left: 0; right: 0; height: 70vh; min-height: 400px; display: flex; align-items: center; justify-content: center; z-index: 1000; font: 16px/1.4 sans-serif; color: #333 }
#tracy-error * { all: initial; background: transparent; color: inherit; font: inherit }
#tracy-error div { max-width: 550px; background: white; display: block }
#tracy-error h1 { font: bold 50px/1.1 sans-serif; margin: 40px; display: block }
#tracy-error p { font: 20px/1.4 sans-serif; margin: 40px; display: block }
#tracy-error small { color: gray; font-size: 80% }
#tracy-error small span { color: silver }
</style>

Expand Down
1 change: 1 addition & 0 deletions tracy-2.10.x/src/Tracy/Dumper/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static function renderAssets(): void

if (!Debugger::isEnabled()) {
$s = '(function(){' . file_get_contents(__DIR__ . '/../assets/toggle.js') . '})();'
. '(function(){' . file_get_contents(__DIR__ . '/../assets/helpers.js') . '})();'
. '(function(){' . file_get_contents(__DIR__ . '/../Dumper/assets/dumper.js') . '})();';
echo "<script{$nonceAttr}>", str_replace(['<!--', '</s'], ['<\!--', '<\/s'], Helpers::minifyJs($s)), "</script>\n";
}
Expand Down
2 changes: 1 addition & 1 deletion tracy-2.10.x/src/Tracy/Dumper/Exposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static function exposeDOMNode(\DOMNode $obj, Value $value, Describer $des
$props = preg_match_all('#^\s*\[([^\]]+)\] =>#m', print_r($obj, return: true), $tmp) ? $tmp[1] : [];
sort($props);
foreach ($props as $p) {
$describer->addPropertyTo($value, $p, $obj->$p, Value::PropertyPublic);
$describer->addPropertyTo($value, $p, @$obj->$p, Value::PropertyPublic); // @ some props may be deprecated
}
}

Expand Down
4 changes: 2 additions & 2 deletions tracy-2.10.x/src/Tracy/Dumper/assets/dumper.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class Dumper {

document.documentElement.addEventListener('click', (e) => {
let el;
// enables <span data-tracy-href=""> & ctrl key
if (e.ctrlKey && (el = e.target.closest('[data-tracy-href]'))) {
// enables <span data-tracy-href=""> & ctrl or cmd key
if ((e.ctrlKey || e.metaKey) && (el = e.target.closest('[data-tracy-href]'))) {
location.href = el.getAttribute('data-tracy-href');
return false;
}
Expand Down
1 change: 0 additions & 1 deletion tracy-2.10.x/src/Tracy/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public static function errorTypeToString(int $type): string
E_USER_WARNING => 'User Warning',
E_NOTICE => 'Notice',
E_USER_NOTICE => 'User Notice',
E_STRICT => 'Strict standards',
E_DEPRECATED => 'Deprecated',
E_USER_DEPRECATED => 'User Deprecated',
];
Expand Down
25 changes: 10 additions & 15 deletions tracy-2.10.x/src/Tracy/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,21 +180,16 @@ protected function sendEmail($message): void
public function defaultMailer($message, string $email): void
{
$host = preg_replace('#[^\w.-]+#', '', $_SERVER['SERVER_NAME'] ?? php_uname('n'));
$parts = str_replace(
["\r\n", "\n"],
["\n", PHP_EOL],
[
'headers' => implode("\n", [
'From: ' . ($this->fromEmail ?: "noreply@$host"),
'X-Mailer: Tracy',
'Content-Type: text/plain; charset=UTF-8',
'Content-Transfer-Encoding: 8bit',
]) . "\n",
'subject' => "PHP: An error occurred on the server $host",
'body' => static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(),
],
mail(
$email,
"PHP: An error occurred on the server $host",
static::formatMessage($message) . "\n\nsource: " . Helpers::getSource(),
implode("\r\n", [
'From: ' . ($this->fromEmail ?: "noreply@$host"),
'X-Mailer: Tracy',
'Content-Type: text/plain; charset=UTF-8',
'Content-Transfer-Encoding: 8bit',
]),
);

mail($email, $parts['subject'], $parts['body'], $parts['headers']);
}
}
2 changes: 1 addition & 1 deletion tracy-2.10.x/src/Tracy/Session/FileSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FileSession implements SessionStorage
public string $cookieName = 'tracy-session';

/** probability that the clean() routine is started */
public float $gcProbability = 0.001;
public float $gcProbability = 0.03;
private string $dir;

/** @var resource */
Expand Down
30 changes: 30 additions & 0 deletions tracy-2.10.x/src/Tracy/assets/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

function init() {
// fixes DNA-106639 "Close tabs created for opening external apps" since Opera 99
if (navigator.userAgent.includes('OPR/')) {
document.addEventListener(
'click',
(e) => {
let el = e.target;
while (el && el !== document) {
if (el.tagName === 'A') {
const href = el.getAttribute('href');
if (href && href.startsWith('editor:')) {
el.setAttribute('target', '_blank');
}
break;
}
el = el.parentNode;
}
},
true,
);
}
}


let Tracy = window.Tracy = window.Tracy || {};
if (!Tracy.helpers) {
init();
Tracy.helpers = true;
}

0 comments on commit bf7603c

Please sign in to comment.