Skip to content

Commit 1ed8d36

Browse files
authored
Merge pull request #2118 from MGatner/toolbar-downloads
Disabled Toolbar on downloads
2 parents 1e61396 + 18a9a08 commit 1ed8d36

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

system/Debug/Toolbar.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use CodeIgniter\Debug\Toolbar\Collectors\History;
4242
use CodeIgniter\Format\JSONFormatter;
4343
use CodeIgniter\Format\XMLFormatter;
44+
use CodeIgniter\HTTP\DownloadResponse;
4445
use CodeIgniter\HTTP\RequestInterface;
4546
use CodeIgniter\HTTP\ResponseInterface;
4647
use Config\Services;
@@ -325,17 +326,25 @@ protected function roundTo(float $number, int $increments = 5): float
325326
/**
326327
* Prepare for debugging..
327328
*
329+
* @param RequestInterface $request
330+
* @param ResponseInterface $response
328331
* @global type $app
329332
* @return type
330333
*/
331-
public function prepare()
334+
public function prepare(RequestInterface $request = null, ResponseInterface $response = null)
332335
{
333336
if (CI_DEBUG && ! is_cli())
334337
{
335338
global $app;
336339

337-
$request = Services::request();
338-
$response = Services::response();
340+
$request = $request ?? Services::request();
341+
$response = $response ?? Services::response();
342+
343+
// Disable the toolbar for downloads
344+
if ($response instanceof DownloadResponse)
345+
{
346+
return;
347+
}
339348

340349
$toolbar = Services::toolbar(config(Toolbar::class));
341350
$stats = $app->getPerformanceStats();

system/Filters/DebugToolbar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function before(RequestInterface $request)
7171
*/
7272
public function after(RequestInterface $request, ResponseInterface $response)
7373
{
74-
Services::toolbar()->prepare();
74+
Services::toolbar()->prepare($request, $response);
7575
}
7676

7777
//--------------------------------------------------------------------

0 commit comments

Comments
 (0)