Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d866a5a

Browse files
committed
bug #9168 [FrameworkBundle] made sure that the debug event dispatcher is used everywhere (fabpot)
This PR was merged into the master branch. Discussion ---------- [FrameworkBundle] made sure that the debug event dispatcher is used everywhere | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #6686, #7673 | License | MIT | Doc PR | n/a The removal of the Profiler dependency on the TraceableEventDispatcher (#9170) allows to remerge the patch from #9068 that fixes #6686. This PR also cleans up how profiles are stored. A Profile is now always stored only once. The fix will only be available on 2.4+ as the changes are too deep to be backported to 2.2 and 2.3. Commits ------- 1e1835e [FrameworkBundle] made sure that the debug event dispatcher is used everywhere
2 parents 5331556 + 1e1835e commit d866a5a

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ public function load(array $configs, ContainerBuilder $container)
6060
if ($container->getParameter('kernel.debug')) {
6161
$loader->load('debug.xml');
6262

63-
// we can't replace the event_dispatcher service with the debug
64-
// one as it would lead to circular references (mainly because the debug
65-
// event dispatcher needs the profiler, which triggers the creation of many
66-
// other services that can depend on the dispatcher itself -- CLI commands
67-
// like assetic:dump and twig:lint exhibits this issue for instance)
6863
$definition = $container->findDefinition('http_kernel');
69-
$arguments = $definition->getArguments();
70-
$arguments[0] = new Reference('debug.event_dispatcher');
71-
$arguments[2] = new Reference('debug.controller_resolver');
72-
$definition->setArguments($arguments);
64+
$definition->replaceArgument(2, new Reference('debug.controller_resolver'));
65+
66+
// replace the regular event_dispatcher service with the debug one
67+
$definition = $container->findDefinition('event_dispatcher');
68+
$definition->setPublic(false);
69+
$container->setDefinition('debug.event_dispatcher.parent', $definition);
70+
$container->setAlias('event_dispatcher', 'debug.event_dispatcher');
7371
}
7472

7573
$configuration = $this->getConfiguration($configs, $container);

src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%">
1818
<tag name="monolog.logger" channel="event" />
19-
<argument type="service" id="event_dispatcher" />
19+
<argument type="service" id="debug.event_dispatcher.parent" />
2020
<argument type="service" id="debug.stopwatch" />
2121
<argument type="service" id="logger" on-invalid="null" />
2222
</service>

src/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ public function __construct($dispatcherService = 'event_dispatcher', $listenerTa
5050

5151
public function process(ContainerBuilder $container)
5252
{
53-
if (!$container->hasDefinition($this->dispatcherService)) {
53+
if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) {
5454
return;
5555
}
5656

57-
$definition = $container->getDefinition($this->dispatcherService);
57+
$definition = $container->findDefinition($this->dispatcherService);
5858

5959
foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) {
6060
$def = $container->getDefinition($id);

src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,11 @@ public function testValidEventSubscriber()
8383
->method('getDefinition')
8484
->will($this->returnValue($definition));
8585

86-
$registerListenersPass = new RegisterListenersPass();
86+
$builder->expects($this->atLeastOnce())
87+
->method('findDefinition')
88+
->will($this->returnValue($definition));
8789

90+
$registerListenersPass = new RegisterListenersPass();
8891
$registerListenersPass->process($builder);
8992
}
9093

0 commit comments

Comments
 (0)