Skip to content

Commit 2449a97

Browse files
bug #19647 [Debug] Swap dumper services at bootstrap (lyrixx)
This PR was merged into the 2.7 branch. Discussion ---------- [Debug] Swap dumper services at bootstrap | 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 | --- 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. Commits ------- d80589c [Debug] Swap dumper services at bootstrap
2 parents 3596cb2 + d80589c commit 2449a97

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/Symfony/Bundle/DebugBundle/DebugBundle.php

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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
}

src/Symfony/Component/HttpKernel/Tests/EventListener/DumpListenerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\EventListener;
1313

14+
use Symfony\Component\Console\ConsoleEvents;
1415
use Symfony\Component\HttpKernel\EventListener\DumpListener;
15-
use Symfony\Component\HttpKernel\KernelEvents;
1616
use Symfony\Component\VarDumper\Cloner\ClonerInterface;
1717
use Symfony\Component\VarDumper\Cloner\Data;
1818
use Symfony\Component\VarDumper\Dumper\DataDumperInterface;
@@ -28,7 +28,7 @@ class DumpListenerTest extends \PHPUnit_Framework_TestCase
2828
public function testSubscribedEvents()
2929
{
3030
$this->assertSame(
31-
array(KernelEvents::REQUEST => array('configure', 1024)),
31+
array(ConsoleEvents::COMMAND => array('configure', 1024)),
3232
DumpListener::getSubscribedEvents()
3333
);
3434
}

0 commit comments

Comments
 (0)