Skip to content

fix: Toolbar when maxHistory is set to 0 #9506

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

Merged
merged 2 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ protected function format(string $data, string $format = 'html'): string
{
$data = json_decode($data, true);

if ($this->config->maxHistory !== 0 && preg_match('/\d+\.\d{6}/s', (string) service('request')->getGet('debugbar_time'), $debugbarTime)) {
if (preg_match('/\d+\.\d{6}/s', (string) service('request')->getGet('debugbar_time'), $debugbarTime)) {
$history = new History();
$history->setFiles(
$debugbarTime[0],
Expand Down
39 changes: 21 additions & 18 deletions system/Debug/Toolbar/Views/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,25 @@ var ciDebugBar = {
.getElementById("debug-icon-link")
.addEventListener("click", ciDebugBar.toggleToolbar, true);

// Allows to highlight the row of the current history request
var btn = this.toolbar.querySelector(
'button[data-time="' + localStorage.getItem("debugbar-time") + '"]'
);
ciDebugBar.addClass(btn.parentNode.parentNode, "current");

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

for (var i = 0; i < historyLoad.length; i++) {
historyLoad[i].addEventListener(
"click",
function () {
loadDoc(this.getAttribute("data-time"));
},
true
if (historyLoad.length) {
// Allows highlighting the row of the current history request
var btn = this.toolbar.querySelector(
'button[data-time="' + localStorage.getItem("debugbar-time-new") + '"]'
);
ciDebugBar.addClass(btn.parentNode.parentNode, "current");


for (var i = 0; i < historyLoad.length; i++) {
historyLoad[i].addEventListener(
"click",
function () {
loadDoc(this.getAttribute("data-time"));
},
true
);
}
}

// Display the active Tab on page load
Expand Down Expand Up @@ -77,14 +80,14 @@ var ciDebugBar = {
links[i].addEventListener("click", function() {
ciDebugBar.toggleDataTable(datatable)
}, true);

} else if (toggleData === "childrows") {

let child = links[i].getAttribute("data-child");
links[i].addEventListener("click", function() {
ciDebugBar.toggleChildRows(child)
}, true);

} else {
links[i].addEventListener("click", ciDebugBar.toggleRows, true);
}
Expand Down Expand Up @@ -174,10 +177,10 @@ var ciDebugBar = {
);

if (target.classList.contains("debug-bar-ndisplay")) {
ciDebugBar.switchClass(target, "debug-bar-ndisplay", "debug-bar-dtableRow");
ciDebugBar.switchClass(target, "debug-bar-ndisplay", "debug-bar-dtableRow");
} else {
ciDebugBar.switchClass(target, "debug-bar-dtableRow", "debug-bar-ndisplay");
}
}
}
},

Expand Down Expand Up @@ -261,7 +264,7 @@ var ciDebugBar = {
} else {
ciDebugBar.switchClass(ciDebugBar.icon, "debug-bar-dinlineBlock", "debug-bar-ndisplay");
ciDebugBar.switchClass(ciDebugBar.toolbar, "debug-bar-ndisplay", "debug-bar-dinlineBlock");
}
}
},

toggleViewsHints: function () {
Expand Down
2 changes: 2 additions & 0 deletions user_guide_src/source/changelogs/v4.6.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Bugs Fixed
- **Database:** Fixed a bug in ``Postgre`` and ``SQLite3`` handlers where composite unique keys were not fully taken into account for ``upsert`` type of queries.
- **Database:** Fixed a bug in the ``OCI8`` and ``SQLSRV`` drivers where ``getVersion()`` returned an empty string when the database connection was not yet established.
- **Logger:** Fixed a bug where the ``{line}`` variable couldn't be used without specifying the ``{file}`` variable when logging the message.
- **Toolbar:** Fixed a bug where setting ``maxHistory`` to ``0`` would produce a JavaScript error in the Debug Toolbar.
- **Toolbar:** Fixed a bug where setting ``maxHistory`` to ``0`` prevented log files from being properly cleared.

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