Skip to content

Commit 2cc95e5

Browse files
committed
[Debug] Swap dumper services at bootstrap
This commit fix a bug when using debug function too soon. For example, if you call dump function during kernel::boot() the dump output will be sent to stderr, even in a web context. With this patch, the data collector is used by default, so the dump output is send to the WDT. In a CLI context, if dump is used too soon, the datacollector will buffer it, and release it at the end of the script. So in this case everything will be visible by the end used.
1 parent adb7033 commit 2cc95e5

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Symfony/Bundle/DebugBundle/DebugBundle.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function boot()
3030
// configuration for CLI mode is overridden in HTTP mode on
3131
// 'kernel.request' event
3232
VarDumper::setHandler(function ($var) use ($container) {
33-
$dumper = $container->get('var_dumper.cli_dumper');
33+
$dumper = $container->get('data_collector.dump');
3434
$cloner = $container->get('var_dumper.cloner');
3535
$handler = function ($var) use ($dumper, $cloner) {
3636
$dumper->dump($cloner->cloneVar($var));

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<service id="debug.dump_listener" class="Symfony\Component\HttpKernel\EventListener\DumpListener">
2323
<tag name="kernel.event_subscriber" />
2424
<argument type="service" id="var_dumper.cloner" />
25-
<argument type="service" id="data_collector.dump" />
25+
<argument type="service" id="var_dumper.cli_dumper" />
2626
</service>
2727

2828
<service id="var_dumper.cloner" class="Symfony\Component\VarDumper\Cloner\VarCloner" />

src/Symfony/Component/HttpKernel/EventListener/DumpListener.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\HttpKernel\EventListener;
1313

14+
use Symfony\Component\Console\ConsoleEvents;
1415
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
15-
use Symfony\Component\HttpKernel\KernelEvents;
1616
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
1717
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
1818
use Symfony\Component\VarDumper\VarDumper;
@@ -50,6 +50,6 @@ public function configure()
5050
public static function getSubscribedEvents()
5151
{
5252
// Register early to have a working dump() as early as possible
53-
return array(KernelEvents::REQUEST => array('configure', 1024));
53+
return array(ConsoleEvents::COMMAND => array('configure', 1024));
5454
}
5555
}

0 commit comments

Comments
 (0)