8000 Keep collecting dumps even when using the dump server and swallowing · symfony/symfony@f24712e · GitHub
[go: up one dir, main page]

Skip to content

Commit f24712e

Browse files
committed
Keep collecting dumps even when using the dump server and swallowing
1 parent 7ae32d8 commit f24712e

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

src/Symfony/Bundle/DebugBundle/DebugBundle.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Symfony\Bundle\DebugBundle\DependencyInjection\Compiler\DumpDataCollectorPass;
1515
use Symfony\Component\DependencyInjection\ContainerBuilder;
1616
use Symfony\Component\HttpKernel\Bundle\Bundle;
17-
use Symfony\Component\VarDumper\Dumper\ServerDumper;
1817
use Symfony\Component\VarDumper\VarDumper;
1918

2019
/**
@@ -33,13 +32,6 @@ public function boot()
3332
VarDumper::setHandler(function ($var) use ($container) {
3433
$dumper = $container->get('data_collector.dump');
3534
$cloner = $container->get('var_dumper.cloner');
36-
37-
if ($container->has(ServerDumper::class)) {
38-
$serverDumper = $container->get(ServerDumper::class);
39-
$serverDumper->setWrappedDumper($dumper);
40-
$dumper = $serverDumper;
41-
}
42-
4335
$handler = function ($var) use ($dumper, $cloner) {
4436
$dumper->dump($cloner->cloneVar($var));
4537
};

src/Symfony/Bundle/DebugBundle/Resources/config/services.xml

Lines changed: 2 additions & 1 deletion
Original file lin 8000 e numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<argument>%kernel.charset%</argument>
2121
<argument type="service" id="request_stack" />
2222
<argument>null</argument><!-- var_dumper.cli_dumper when debug.dump_destination is set -->
23+
<argument type="service" id="Symfony\Component\VarDumper\Dumper\ServerDumper" on-invalid="null" />
2324
</service>
2425

2526
<service id="debug.dump_listener" class="Symfony\Component\HttpKernel\EventListener\DumpListener" public="true">
@@ -30,7 +31,7 @@
3031
</service>
3132

3233
<service id="var_dumper.cloner" class="Symfony\Component\VarDumper\Cloner\VarCloner" public="true" />
33-
<service id="Symfony\Component\VarDumper\Dumper\ServerDumper" public="true">
34+
<service id="Symfony\Component\VarDumper\Dumper\ServerDumper">
3435
<argument /> <!-- server host -->
3536
<argument type="service" id="var_dumper.cli_dumper" />
3637
<argument /> <!-- whether to swallow or not wrapped dumper -->

src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\VarDumper\Dumper\CliDumper;
2121
use Symfony\Component\VarDumper\Dumper\HtmlDumper;
2222
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
23+
use Symfony\Component\VarDumper\Dumper\ServerDumper;
2324
use Twig\Template;
2425

2526
/**
@@ -38,15 +39,17 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
3839
private $requestStack;
3940
private $dumper;
4041
private $dumperIsInjected;
42+
private $serverDumper;
4143

42-
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $charset = null, RequestStack $requestStack = null, DataDumperInterface $dumper = null)
44+
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null, $charset = null, RequestStack $requestStack = null, DataDumperInterface $dumper = null, ServerDumper $serverDumper = null)
4345
{
4446
$this->stopwatch = $stopwatch;
4547
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
4648
$this->charset = $charset ?: ini_get('php.output_encoding') ?: ini_get('default_charset') ?: 'UTF-8';
4749
$this->requestStack = $requestStack;
4850
$this->dumper = $dumper;
4951
$this->dumperIsInjected = null !== $dumper;
52+
$this->serverDumper = $serverDumper;
5053

5154
// All clones share these properties by reference:
5255
$this->rootRefs = array(
@@ -257,8 +260,17 @@ public function __destruct()
257260

258261
private function doDump($data, $name, $file, $line)
259262
{
263+
$dumper = $this->serverDumper ?: $this->dumper;
264+
if ($dumper instanceof ServerDumper) {
265+
$dumper->setWrappedDumper($this->dumper);
266+
}
267+
260268
if ($this->dumper instanceof CliDumper) {
261269
$contextDumper = function ($name, $file, $line, $fmt) {
270+
if ($this instanceof ServerDumper) {
271+
return;
272+
}
273+
262274
if ($this instanceof HtmlDumper) {
263275
if ($file) {
264276
$s = $this->style('meta', '%s');
@@ -278,13 +290,13 @@ private function doDump($data, $name, $file, $line)
278290
}
279291
$this->dumpLine(0);
280292
};
281-
$contextDumper = $contextDumper->bindTo($this->dumper, $this->dumper);
293+
$contextDumper = $contextDumper->bindTo($dumper, $dumper);
282294
$contextDumper($name, $file, $line, $this->fileLinkFormat);
283295
} else {
284296
$cloner = new VarCloner();
285-
$this->dumper->dump($cloner->cloneVar($name.' on line '.$line.':'));
297+
$dumper->dump($cloner->cloneVar($name.' on line '.$line.':'));
286298
}
287-
$this->dumper->dump($data);
299+
$dumper->dump($data);
288300
}
289301

290302
private function htmlEncode($s)

0 commit comments

Comments
 (0)
0