[DebugBundle] Always collect dumps

This commit is contained in:
Nicolas Grekas 2015-05-13 12:14:36 +02:00
parent a7019ced63
commit 8cb2abbd26
2 changed files with 9 additions and 9 deletions

View File

@ -123,11 +123,11 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
if ($this->dumper) { if ($this->dumper) {
$this->doDump($data, $name, $file, $line); $this->doDump($data, $name, $file, $line);
} else {
$this->data[] = compact('data', 'name', 'file', 'line', 'fileExcerpt');
++$this->dataCount;
} }
$this->data[] = compact('data', 'name', 'file', 'line', 'fileExcerpt');
++$this->dataCount;
if ($this->stopwatch) { if ($this->stopwatch) {
$this->stopwatch->stop('dump'); $this->stopwatch->stop('dump');
} }
@ -136,7 +136,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
public function collect(Request $request, Response $response, \Exception $exception = null) public function collect(Request $request, Response $response, \Exception $exception = null)
{ {
// Sub-requests and programmatic calls stay in the collected profile. // Sub-requests and programmatic calls stay in the collected profile.
if (($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) { if ($this->dumper || ($this->requestStack && $this->requestStack->getMasterRequest() !== $request) || $request->isXmlHttpRequest() || $request->headers->has('Origin')) {
return; return;
} }
@ -154,13 +154,9 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
$this->dumper = new CliDumper('php://output', $this->charset); $this->dumper = new CliDumper('php://output', $this->charset);
} }
foreach ($this->data as $i => $dump) { foreach ($this->data as $dump) {
$this->data[$i] = null;
$this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']); $this->doDump($dump['data'], $dump['name'], $dump['file'], $dump['line']);
} }
$this->data = array();
$this->dataCount = 0;
} }
} }

View File

@ -72,6 +72,8 @@ class DumpDataCollectorTest extends \PHPUnit_Framework_TestCase
$output = ob_get_clean(); $output = ob_get_clean();
$this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output); $this->assertSame("DumpDataCollectorTest.php on line {$line}:\n123\n", $output);
$this->assertSame(1, $collector->getDumpsCount());
$collector->serialize();
} }
public function testCollectHtml() public function testCollectHtml()
@ -99,6 +101,8 @@ EOTXT;
$output = preg_replace('/sf-dump-\d+/', 'sf-dump', $output); $output = preg_replace('/sf-dump-\d+/', 'sf-dump', $output);
$this->assertSame($xOutput, $output); $this->assertSame($xOutput, $output);
$this->assertSame(1, $collector->getDumpsCount());
$collector->serialize();
} }
public function testFlush() public function testFlush()