Skip to content

Commit 65464cd

Browse files
committed
fix: debugbar when maxHistory is set to 0
1 parent 6fbf601 commit 65464cd

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

system/Debug/Toolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ protected function format(string $data, string $format = 'html'): string
512512
{
513513
$data = json_decode($data, true);
514514

515-
if ($this->config->maxHistory !== 0 && preg_match('/\d+\.\d{6}/s', (string) service('request')->getGet('debugbar_time'), $debugbarTime)) {
515+
if (preg_match('/\d+\.\d{6}/s', (string) service('request')->getGet('debugbar_time'), $debugbarTime)) {
516516
$history = new History();
517517
$history->setFiles(
518518
$debugbarTime[0],

system/Debug/Toolbar/Views/toolbar.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ var ciDebugBar = {
2727
.getElementById("debug-icon-link")
2828
.addEventListener("click", ciDebugBar.toggleToolbar, true);
2929

30-
// Allows to highlight the row of the current history request
31-
var btn = this.toolbar.querySelector(
32-
'button[data-time="' + localStorage.getItem("debugbar-time") + '"]'
33-
);
34-
ciDebugBar.addClass(btn.parentNode.parentNode, "current");
30+
if (this.toolbar.querySelector(".ci-history-load")) {
31+
// Allows highlighting the row of the current history request
32+
var btn = this.toolbar.querySelector(
33+
'button[data-time="' + localStorage.getItem("debugbar-time") + '"]'
34+
);
35+
ciDebugBar.addClass(btn.parentNode.parentNode, "current");
36+
}
3537

3638
historyLoad = this.toolbar.getElementsByClassName("ci-history-load");
3739

@@ -77,14 +79,14 @@ var ciDebugBar = {
7779
links[i].addEventListener("click", function() {
7880
ciDebugBar.toggleDataTable(datatable)
7981
}, true);
80-
82+
8183
} else if (toggleData === "childrows") {
8284

8385
let child = links[i].getAttribute("data-child");
8486
links[i].addEventListener("click", function() {
8587
ciDebugBar.toggleChildRows(child)
8688
}, true);
87-
89+
8890
} else {
8991
links[i].addEventListener("click", ciDebugBar.toggleRows, true);
9092
}
@@ -174,10 +176,10 @@ var ciDebugBar = {
174176
);
175177

176178
if (target.classList.contains("debug-bar-ndisplay")) {
177-
ciDebugBar.switchClass(target, "debug-bar-ndisplay", "debug-bar-dtableRow");
179+
ciDebugBar.switchClass(target, "debug-bar-ndisplay", "debug-bar-dtableRow");
178180
} else {
179181
ciDebugBar.switchClass(target, "debug-bar-dtableRow", "debug-bar-ndisplay");
180-
}
182+
}
181183
}
182184
},
183185

@@ -261,7 +263,7 @@ var ciDebugBar = {
261263
} else {
262264
ciDebugBar.switchClass(ciDebugBar.icon, "debug-bar-dinlineBlock", "debug-bar-ndisplay");
263265
ciDebugBar.switchClass(ciDebugBar.toolbar, "debug-bar-ndisplay", "debug-bar-dinlineBlock");
264-
}
266+
}
265267
},
266268

267269
toggleViewsHints: function () {

user_guide_src/source/changelogs/v4.6.1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Bugs Fixed
3535
- **Database:** Fixed a bug in ``Postgre`` and ``SQLite3`` handlers where composite unique keys were not fully taken into account for ``upsert`` type of queries.
3636
- **Database:** Fixed a bug in the ``OCI8`` and ``SQLSRV`` drivers where ``getVersion()`` returned an empty string when the database connection was not yet established.
3737
- **Logger:** Fixed a bug where the ``{line}`` variable couldn't be used without specifying the ``{file}`` variable when logging the message.
38+
- **Toolbar:** Fixed a bug where setting ``maxHistory`` to ``0`` would produce a JavaScript error in the Debug Toolbar.
39+
- **Toolbar:** Fixed a bug where setting ``maxHistory`` to ``0`` prevented log files from being properly cleared.
3840

3941
See the repo's
4042
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_

0 commit comments

Comments
 (0)