From b46cc519644fde67687019603d08677a6d963a7d Mon Sep 17 00:00:00 2001 From: Sebastian Helzle Date: Mon, 14 Dec 2020 16:27:25 +0100 Subject: [PATCH 1/2] BUGFIX: Only load debug script when format is html --- Classes/Aspect/CollectDebugInformationAspect.php | 5 +++++ Classes/Aspect/ContentCacheSegmentAspect.php | 7 +++++++ Resources/Private/Fusion/Root.fusion | 1 + 3 files changed, 13 insertions(+) diff --git a/Classes/Aspect/CollectDebugInformationAspect.php b/Classes/Aspect/CollectDebugInformationAspect.php index d61fd43..3bce945 100644 --- a/Classes/Aspect/CollectDebugInformationAspect.php +++ b/Classes/Aspect/CollectDebugInformationAspect.php @@ -110,6 +110,11 @@ public function addDebugValues(JoinPointInterface $joinPoint) if ($response instanceof Response) { $output = $response->getBody()->getContents(); + + if ($response->getHeader('Content-Type') !== 'text/html' + && strpos($output, '') === false) { + return $response; + } } else { $output = $response; } diff --git a/Classes/Aspect/ContentCacheSegmentAspect.php b/Classes/Aspect/ContentCacheSegmentAspect.php index 964b962..e8abd87 100644 --- a/Classes/Aspect/ContentCacheSegmentAspect.php +++ b/Classes/Aspect/ContentCacheSegmentAspect.php @@ -176,6 +176,13 @@ protected function renderCacheInfoIntoSegment($segment, array $info): string + ['fusionObject' => ObjectAccess::getProperty($this->interceptedFusionObject, 'fusionObjectName', true)] + array_slice($info, $injectPosition, count($info) - $injectPosition, true); + // Add debug data only to html output + $segmentFormat = $info['entryIdentifier']['format'] ?? null; + + if ($segmentFormat !== 'html') { + return $segment; + } + $info['created'] = (new \DateTime())->format(DATE_W3C); $cCacheDebugData = ''; diff --git a/Resources/Private/Fusion/Root.fusion b/Resources/Private/Fusion/Root.fusion index 650bb8f..888f237 100644 --- a/Resources/Private/Fusion/Root.fusion +++ b/Resources/Private/Fusion/Root.fusion @@ -22,6 +22,7 @@ prototype(t3n.Neos.Debug:JavaScript) < prototype(Neos.Fusion:Tag) { } @if.notInBackend = ${!documentNode.context.inBackend} + @if.isHtml = ${request.format == 'html'} @if.isActive = ${Configuration.setting('t3n.Neos.Debug.enabled') && Configuration.setting('t3n.Neos.Debug.htmlOutput.enabled')} @position = 'before closingBodyTag' } From 3169550c2a9e868537e5def1b013405594490346 Mon Sep 17 00:00:00 2001 From: Sebastian Helzle Date: Wed, 16 Dec 2020 10:11:25 +0100 Subject: [PATCH 2/2] =?UTF-8?q?BUGFIX:=20Don=E2=80=99t=20init=20script=20w?= =?UTF-8?q?ithout=20debug=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Resources/Public/Script/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/Public/Script/main.js b/Resources/Public/Script/main.js index 1145108..1fbfac1 100644 --- a/Resources/Public/Script/main.js +++ b/Resources/Public/Script/main.js @@ -33,6 +33,9 @@ window.__enable_neos_debug__ = (setCookie = false) => { if (dataNode) { debugInfos = JSON.parse(dataNode.nodeValue.substring(DEBUG_PREFIX.length)); } + + if (!Object.keys(debugInfos).length) return; + debugInfos.cCacheUncached = 0; // Takes an ISO time and returns a string representing how