Skip to content

Commit

Permalink
Merge pull request #120 from Sebobo/bugfix/only-add-debug-to-html
Browse files Browse the repository at this point in the history
BUGFIX: Only add debug output to html
  • Loading branch information
Sebobo committed Dec 16, 2020
2 parents e52351e + 3169550 commit 8bc73c6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Classes/Aspect/CollectDebugInformationAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, '<!DOCTYPE html>') === false) {
return $response;
}
} else {
$output = $response;
}
Expand Down
7 changes: 7 additions & 0 deletions Classes/Aspect/ContentCacheSegmentAspect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<!--__T3N_CONTENT_CACHE_DEBUG__ ' . json_encode($info) . ' -->';
Expand Down
1 change: 1 addition & 0 deletions Resources/Private/Fusion/Root.fusion
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down
3 changes: 3 additions & 0 deletions Resources/Public/Script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8bc73c6

Please sign in to comment.