From 55a93566817d4a38702a38c740ac404872bf7ec7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 26 Dec 2016 09:47:51 -0700 Subject: [PATCH] Fix for #1227 issue - Admin JSON calls throwing errors with debugger on --- CHANGELOG.md | 6 ++++++ system/src/Grav/Common/Debugger.php | 8 ++++++++ system/src/Grav/Common/Page/Page.php | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a13ea0a53..5b35b90195 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.1.12 +## 12/26/2016 + +1. [](#bugfix) + * Fixed issue with JSON calls throwing errors due to debugger enabled [#1227](https://github.com/getgrav/grav/issues/1227) + # v1.1.11 ## 12/22/2016 diff --git a/system/src/Grav/Common/Debugger.php b/system/src/Grav/Common/Debugger.php index 3784b87247..87bdee357a 100644 --- a/system/src/Grav/Common/Debugger.php +++ b/system/src/Grav/Common/Debugger.php @@ -87,6 +87,14 @@ public function enabled($state = null) public function addAssets() { if ($this->enabled()) { + + // Only add assets if Page is HTML + $page = $this->grav['page']; + if ($page->templateFormat() != 'html') { + $this->enabled = false; + return; + } + /** @var Assets $assets */ $assets = $this->grav['assets']; diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index fb683cae5f..ff295b6e93 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1123,7 +1123,7 @@ public function templateFormat($var = null) } if (empty($this->template_format)) { - $this->template_format = Grav::instance()['uri']->extension(); + $this->template_format = Grav::instance()['uri']->extension('html'); } return $this->template_format;