bug #19623 [VarDumper] Fix dumping continuations (nicolas-grekas)
This PR was merged into the 2.7 branch.
Discussion
----------
[VarDumper] Fix dumping continuations
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
Dumping twice on the same destination shouldn't dump headers again.
Commits
-------
da96719
[VarDumper] Fix dumping continuations
This commit is contained in:
commit
adb7033fc2
@ -211,8 +211,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
|
|||||||
// getLimitedClone is @deprecated, to be removed in 3.0
|
// getLimitedClone is @deprecated, to be removed in 3.0
|
||||||
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
|
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
|
||||||
}
|
}
|
||||||
rewind($data);
|
$dump['data'] = stream_get_contents($data, -1, 0);
|
||||||
$dump['data'] = stream_get_contents($data);
|
|
||||||
ftruncate($data, 0);
|
ftruncate($data, 0);
|
||||||
rewind($data);
|
rewind($data);
|
||||||
$dumps[] = $dump;
|
$dumps[] = $dump;
|
||||||
|
@ -54,18 +54,6 @@ class HtmlDumper extends CliDumper
|
|||||||
$this->dumpId = 'sf-dump-'.mt_rand();
|
$this->dumpId = 'sf-dump-'.mt_rand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function setOutput($output)
|
|
||||||
{
|
|
||||||
if ($output !== $prev = parent::setOutput($output)) {
|
|
||||||
$this->headerIsDumped = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $prev;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -111,7 +99,7 @@ class HtmlDumper extends CliDumper
|
|||||||
*/
|
*/
|
||||||
protected function getDumpHeader()
|
protected function getDumpHeader()
|
||||||
{
|
{
|
||||||
$this->headerIsDumped = true;
|
$this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
|
||||||
|
|
||||||
if (null !== $this->dumpHeader) {
|
if (null !== $this->dumpHeader) {
|
||||||
return $this->dumpHeader;
|
return $this->dumpHeader;
|
||||||
@ -433,7 +421,7 @@ EOHTML;
|
|||||||
if (-1 === $this->lastDepth) {
|
if (-1 === $this->lastDepth) {
|
||||||
$this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
|
$this->line = sprintf($this->dumpPrefix, $this->dumpId, $this->indentPad).$this->line;
|
||||||
}
|
}
|
||||||
if (!$this->headerIsDumped) {
|
if ($this->headerIsDumped !== (null !== $this->outputStream ? $this->outputStream : $this->lineDumper)) {
|
||||||
$this->line = $this->getDumpHeader().$this->line;
|
$this->line = $this->getDumpHeader().$this->line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,8 +132,7 @@ EOTXT
|
|||||||
$data = $cloner->cloneVar($var);
|
$data = $cloner->cloneVar($var);
|
||||||
$out = fopen('php://memory', 'r+b');
|
$out = fopen('php://memory', 'r+b');
|
||||||
$dumper->dump($data, $out);
|
$dumper->dump($data, $out);
|
||||||
rewind($out);
|
$out = stream_get_contents($out, -1, 0);
|
||||||
$out = stream_get_contents($out);
|
|
||||||
|
|
||||||
$this->assertStringMatchesFormat(
|
$this->assertStringMatchesFormat(
|
||||||
<<<EOTXT
|
<<<EOTXT
|
||||||
@ -142,7 +141,32 @@ EOTXT
|
|||||||
|
|
||||||
EOTXT
|
EOTXT
|
||||||
,
|
,
|
||||||
|
$out
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAppend()
|
||||||
|
{
|
||||||
|
$out = fopen('php://memory', 'r+b');
|
||||||
|
|
||||||
|
$dumper = new HtmlDumper();
|
||||||
|
$dumper->setDumpHeader('<foo></foo>');
|
||||||
|
$dumper->setDumpBoundaries('<bar>', '</bar>');
|
||||||
|
$cloner = new VarCloner();
|
||||||
|
|
||||||
|
$dumper->dump($cloner->cloneVar(123), $out);
|
||||||
|
$dumper->dump($cloner->cloneVar(456), $out);
|
||||||
|
|
||||||
|
$out = stream_get_contents($out, -1, 0);
|
||||||
|
|
||||||
|
$this->assertSame(<<<'EOTXT'
|
||||||
|
<foo></foo><bar><span class=sf-dump-num>123</span>
|
||||||
|
</bar>
|
||||||
|
<bar><span class=sf-dump-num>456</span>
|
||||||
|
</bar>
|
||||||
|
|
||||||
|
EOTXT
|
||||||
|
,
|
||||||
$out
|
$out
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user