From c73003721a408cb59ec33c6901257838246dd2eb Mon Sep 17 00:00:00 2001 From: "Barry vd. Heuvel" Date: Tue, 18 Nov 2014 15:03:50 +0100 Subject: [PATCH] Tweak order Fixes #227 --- src/LaravelDebugBar.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/LaravelDebugBar.php b/src/LaravelDebugBar.php index 7d6a6a4b..7c9bf19c 100644 --- a/src/LaravelDebugBar.php +++ b/src/LaravelDebugBar.php @@ -514,33 +514,29 @@ public function modifyResponse($request, $response) } } - if ($response->isRedirection()) { + if ($response->isRedirection() || !($request instanceof \Illuminate\Http\Request)) { try { $this->stackData(); } catch (\Exception $e) { $app['log']->error('Debugbar exception: ' . $e->getMessage()); } } elseif ( - !($request instanceof \Illuminate\Http\Request) - || ($response->headers->has('Content-Type') && false === strpos( - $response->headers->get('Content-Type'), - 'html' - )) - || 'html' !== $request->format() + ($request->isXmlHttpRequest() || $request->wantsJson()) and + $app['config']->get('laravel-debugbar::config.capture_ajax', true) ) { try { - // Just collect + store data, don't inject it. - $this->collect(); + $this->sendDataInHeaders(true); } catch (\Exception $e) { $app['log']->error('Debugbar exception: ' . $e->getMessage()); } - } elseif (($request->isXmlHttpRequest() || $request->wantsJson()) and $app['config']->get( - 'laravel-debugbar::config.capture_ajax', - true - ) + } elseif ( + ($response->headers->has('Content-Type') and + strpos($response->headers->get('Content-Type'), 'html') === false) + || 'html' !== $request->format() ) { try { - $this->sendDataInHeaders(true); + // Just collect + store data, don't inject it. + $this->collect(); } catch (\Exception $e) { $app['log']->error('Debugbar exception: ' . $e->getMessage()); }