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
|
||||
$dumper->dump($dump['data']->getLimitedClone($maxDepthLimit, $maxItemsPerDepth));
|
||||
}
|
||||
rewind($data);
|
||||
$dump['data'] = stream_get_contents($data);
|
||||
$dump['data'] = stream_get_contents($data, -1, 0);
|
||||
ftruncate($data, 0);
|
||||
rewind($data);
|
||||
$dumps[] = $dump;
|
||||
|
|
|
@ -54,18 +54,6 @@ class HtmlDumper extends CliDumper
|
|||
$this->dumpId = 'sf-dump-'.mt_rand();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOutput($output)
|
||||
{
|
||||
if ($output !== $prev = parent::setOutput($output)) {
|
||||
$this->headerIsDumped = false;
|
||||
}
|
||||
|
||||
return $prev;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -111,7 +99,7 @@ class HtmlDumper extends CliDumper
|
|||
*/
|
||||
protected function getDumpHeader()
|
||||
{
|
||||
$this->headerIsDumped = true;
|
||||
$this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;
|
||||
|
||||
if (null !== $this->dumpHeader) {
|
||||
return $this->dumpHeader;
|
||||
|
@ -433,7 +421,7 @@ EOHTML;
|
|||
if (-1 === $this->lastDepth) {
|
||||
$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;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,8 +132,7 @@ EOTXT
|
|||
$data = $cloner->cloneVar($var);
|
||||
$out = fopen('php://memory', 'r+b');
|
||||
$dumper->dump($data, $out);
|
||||
rewind($out);
|
||||
$out = stream_get_contents($out);
|
||||
$out = stream_get_contents($out, -1, 0);
|
||||
|
||||
$this->assertStringMatchesFormat(
|
||||
<<<EOTXT
|
||||
|
@ -142,7 +141,32 @@ 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
|
||||
);
|
||||
}
|
||||
|
|
Reference in New Issue