Skip to content
Snippets Groups Projects
Commit 03c0ce44 authored by Maddy Chellathurai's avatar Maddy Chellathurai
Browse files

Merge remote-tracking branch 'ogresCE/MAGETWO-39576-Profiler-JSON' into PR_Branch

parents badfac49 2ef56e3e
Branches
No related merge requests found
...@@ -76,6 +76,11 @@ class BuiltinPlugin ...@@ -76,6 +76,11 @@ class BuiltinPlugin
$this->kernel->process($result); $this->kernel->process($result);
} }
} else { } else {
json_decode($result->getContent());
if (json_last_error() == JSON_ERROR_NONE) {
// reset profiler to avoid appending profiling stat to JSON response
\Magento\Framework\Profiler::reset();
}
$this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'HIT', true); $this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'HIT', true);
} }
return $result; return $result;
......
...@@ -200,6 +200,7 @@ class BuiltinPluginTest extends \PHPUnit_Framework_TestCase ...@@ -200,6 +200,7 @@ class BuiltinPluginTest extends \PHPUnit_Framework_TestCase
$this->responseMock->expects($this->never()) $this->responseMock->expects($this->never())
->method('setHeader'); ->method('setHeader');
} }
$this->responseMock->expects($this->once())->method('getContent');
$this->assertSame( $this->assertSame(
$this->responseMock, $this->responseMock,
$this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock) $this->plugin->aroundDispatch($this->frontControllerMock, $this->closure, $this->requestMock)
......
...@@ -63,6 +63,8 @@ class Json extends AbstractResult ...@@ -63,6 +63,8 @@ class Json extends AbstractResult
*/ */
protected function render(ResponseInterface $response) protected function render(ResponseInterface $response)
{ {
// reset profiler to avoid appending profiling stat to JSON response
\Magento\Framework\Profiler::reset();
$this->translateInline->processResponseBody($this->json, true); $this->translateInline->processResponseBody($this->json, true);
$response->representJson($this->json); $response->representJson($this->json);
return $this; return $this;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment