8000 bug #29714 [Event Dispatcher] fixed 29703: TraceableEventDispatcher r… · symfony/symfony@f82beb5 · GitHub
[go: up one dir, main page]

Skip to content

Commit f82beb5

Browse files
committed
bug #29714 [Event Dispatcher] fixed 29703: TraceableEventDispatcher reset() callStack to null (mlievertz)
This PR was merged into the 3.4 branch. Discussion ---------- [Event Dispatcher] fixed 29703: TraceableEventDispatcher reset() callStack to null [Event Dispatcher] fixed 29703: TraceableEventDispatcher reset now sets callStack to null with test to dispatch after reset. | Q | A | ------------- | --- | Branch? | 3.4 <!-- see below --> | Bug fix? | yes | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #29703 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A <!-- required for new features --> [Event Dispatcher] fixed 29703: TraceableEventDispatcher reset now sets callStack to null with test to dispatch after reset. Basically #29411 introduced an issue where calling dispatch after a reset would throw an error because now reset set callStack to array but dispatch expected either SplObjectStorage or null. Now reset sets null. Also added a test to verify dispatch works following a call to reset. Commits ------- 51bcdb8 [Event Dispatcher] fixed 29703: TraceableEventDispatcher reset now sets callStack to null with test to dispatch after reset.
2 parents 042f604 + 51bcdb8 commit f82beb5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ public function getNotCalledListeners()
221221

222222
public function reset()
223223
{
224-
$this->callStack = array();
224+
$this->callStack = null;
225225
}
226226

227227
/**

src/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ public function testClearCalledListeners()
139139
$this->assertEquals(array(array('event' => 'foo', 'pretty' => 'closure', 'priority' => 5)), $listeners);
140140
}
141141

142+
public function testDispatchAfterReset()
143+
{
144+
$tdispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch());
145+
$tdispatcher->addListener('foo', function () {}, 5);
146+
147+
$tdispatcher->reset();
148+
$tdispatcher->dispatch('foo');
149+
150+
$listeners = $tdispatcher->getCalledListeners();
151+
$this->assertArrayHasKey('stub', $listeners[0]);
152+
}
153+
142154
public function testGetCalledListenersNested()
143155
{
144156
$tdispatcher = null;

0 commit comments

Comments
 (0)
0