Skip to content

Commit

Permalink
Merge pull request #2118 from MGatner/toolbar-downloads
Browse files Browse the repository at this point in the history
Disabled Toolbar on downloads
  • Loading branch information
lonnieezell authored Aug 2, 2019
2 parents 1e61396 + 18a9a08 commit 1ed8d36
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use CodeIgniter\Debug\Toolbar\Collectors\History;
use CodeIgniter\Format\JSONFormatter;
use CodeIgniter\Format\XMLFormatter;
use CodeIgniter\HTTP\DownloadResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Config\Services;
Expand Down Expand Up @@ -325,17 +326,25 @@ protected function roundTo(float $number, int $increments = 5): float
/**
* Prepare for debugging..
*
* @param RequestInterface $request
* @param ResponseInterface $response
* @global type $app
* @return type
*/
public function prepare()
public function prepare(RequestInterface $request = null, ResponseInterface $response = null)
{
if (CI_DEBUG && ! is_cli())
{
global $app;

$request = Services::request();
$response = Services::response();
$request = $request ?? Services::request();
$response = $response ?? Services::response();

// Disable the toolbar for downloads
if ($response instanceof DownloadResponse)
{
return;
}

$toolbar = Services::toolbar(config(Toolbar::class));
$stats = $app->getPerformanceStats();
Expand Down
2 changes: 1 addition & 1 deletion system/Filters/DebugToolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function before(RequestInterface $request)
*/
public function after(RequestInterface $request, ResponseInterface $response)
{
Services::toolbar()->prepare();
Services::toolbar()->prepare($request, $response);
}

//--------------------------------------------------------------------
Expand Down

0 comments on commit 1ed8d36

Please sign in to comment.