8000 bug #29822 [EventDispatcher] Fix unknown priority (ro0NL) · symfony/symfony@da16b9c · GitHub
[go: up one dir, main page]

Skip to content

Commit da16b9c

Browse files
committed
bug #29822 [EventDispatcher] Fix unknown priority (ro0NL)
This PR was merged into the 3.4 branch. Discussion ---------- [EventDispatcher] Fix unknown priority | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Somehow, after #29411 the profiler actually shows the security firewall `ContextListener`. This listener removes itself at call time, but at this point it's wrapped reference is already in the call stack; to be displayed in the profiler. Because the wrapped listener lazily collects its priority - it asks it from the dispatcher - we get null; the listener was already removed. This causes the profiler to render `-` by default: ![image](https://user-images.githubusercontent.com/1047696/50850320-d5c5ee80-1379-11e9-8516-0c6bc54512ce.png) This fixes it by always passing the expected priority at call time. Commits ------- 9fb619a [EventDispatcher] Fix unknown priority
2 parents eb7a612 + 9fb619a commit da16b9c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class WrappedListener
2929
private $dispatcher;
3030
private $pretty;
3131
private $stub;
32+
private $priority;
3233
private static $hasClassStub;
3334

3435
public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
@@ -96,19 +97,22 @@ public function getInfo($eventName)
9697

9798
return [
9899
'event' => $eventName,
99-
'priority' => null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null,
100+
'priority' => null !== $this->priority ? $this->priority : (null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null),
100101
'pretty' => $this->pretty,
101102
'stub' => $this->stub,
102103
];
103104
}
104105

105106
public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher)
106107
{
108+
$dispatcher = $this->dispatcher ?: $dispatcher;
109+
107110
$this->called = true;
111+
$this->priority = $dispatcher->getListenerPriority($eventName, $this->listener);
108112

109113
$e = $this->stopwatch->start($this->name, 'event_listener');
110114

111-
\call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
115+
\call_user_func($this->listener, $event, $eventName, $dispatcher);
112116

113117
if ($e->isStarted()) {
114118
$e->stop();

0 commit comments

Comments
 (0)
0