bug #27913 [EventDispatcher] Clear orphaned events on reset (acasademont)
This PR was merged into the 4.1 branch.
Discussion
----------
[EventDispatcher] Clear orphaned events on reset
| Q | A
| ------------- | ---
| Branch? | 4.1
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | NA
| License | MIT
| Doc PR | NA
When the Orphaned Events feature was added in #24392 it was forgotten to also clear them when the `reset` method on the `TraceableEventDispatcher` is called. This makes the Orphaned Events tab on the Event profiler an evergrowing list when using PHP-PM (or other event loop implementations).
Commits
-------
d3260dfdcd
[EventDispatcher] Clear orphaned events on TraceableEventDispatcher::reset
This commit is contained in:
commit
10f7dcc5dc
@ -217,6 +217,7 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
||||
public function reset()
|
||||
{
|
||||
$this->called = array();
|
||||
$this->orphanedEvents = array();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -271,6 +271,17 @@ class TraceableEventDispatcherTest extends TestCase
|
||||
|
||||
$this->assertCount(1, $eventDispatcher->getListeners('foo'), 'expected listener1 to be removed');
|
||||
}
|
||||
|
||||
public function testClearOrphanedEvents()
|
||||
{
|
||||
$tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
|
||||
$tdispatcher->dispatch('foo');
|
||||
$events = $tdispatcher->getOrphanedEvents();
|
||||
$this->assertCount(1, $events);
|
||||
$tdispatcher->reset();
|
||||
$events = $tdispatcher->getOrphanedEvents();
|
||||
$this->assertCount(0, $events);
|
||||
}
|
||||
}
|
||||
|
||||
class EventSubscriber implements EventSubscriberInterface
|
||||
|
Reference in New Issue
Block a user