Skip to content

[VarDumper] Fix dumping continuations #19623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[VarDumper] Fix dumping continuations
  • Loading branch information
nicolas-grekas committed Aug 16, 2016
commit da96719b94fae82ab7fc1c783256f53f47f50975
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ public function getDumps($format, $maxDepthLimit = -1, $maxItemsPerDepth = -1)
// 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;
Expand Down
16 changes: 2 additions & 14 deletions src/Symfony/Component/VarDumper/Dumper/HtmlDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,6 @@ public function __construct($output = null, $charset = null)
$this->dumpId = 'sf-dump-'.mt_rand();
}

/**
* {@inheritdoc}
*/
public function setOutput($output)
{
if ($output !== $prev = parent::setOutput($output)) {
$this->headerIsDumped = false;
}

return $prev;
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -111,7 +99,7 @@ public function dump(Data $data, $output = null)
*/
protected function getDumpHeader()
{
$this->headerIsDumped = true;
$this->headerIsDumped = null !== $this->outputStream ? $this->outputStream : $this->lineDumper;

if (null !== $this->dumpHeader) {
return $this->dumpHeader;
Expand Down Expand Up @@ -433,7 +421,7 @@ protected function dumpLine($depth, $endOfValue = false)
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;
}

Expand Down
28 changes: 26 additions & 2 deletions src/Symfony/Component/VarDumper/Tests/HtmlDumperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ public function testCharset()
$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
Expand All @@ -142,7 +141,32 @@ public function testCharset()

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
);
}
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy