Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[EventDispatcher] Fix eventListener wrapper loop in TraceableEventDispatcher#29376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:3.4fromjderusse:fix-wrap-loop
Dec 1, 2018

Conversation

@jderusse
Copy link
Member

QA
Branch?3.4
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsnone
LicenseMIT
Doc PRna

TheTracableEventDispatcher wrap decorate (in the methodpreProcess) each listeners in aWrappedListener before delegating the dispatch to the real dispatcher, then remove the wrapper (in the methodpostProcess.

But, if a listener triggers an exception, thepostProcess method is not called, and the wrapper in not removed.
If the same event is triggered a second time, the listeners will be decorated twice, etc, etc..
This is an issue with php-pm where the same event is triggered hundred of times within the same process.

This PR moves thepostProcess in a finally block in order to be called even if an exception in thrown.

@ro0NL
Copy link
Contributor

👍 included this also in#29312

@chalasrchalasr changed the title[EventDispatcher] Fix eventListener wrapper loop in TracableEventDispatcher[EventDispatcher] Fix eventListener wrapper loop in TraceableEventDispatcherNov 30, 2018
}
}
}finally {
$this->postDispatch($eventName,$event);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

in#29312 i actually hesitated if we should call postDispatch after exception. That's a new behavior, where the user cant act upon as it doesnt know about an errored dispatch call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hm, looking at

protectedfunctionpostDispatch($eventName,Event$event)
{
switch ($eventName) {
case KernelEvents::CONTROLLER_ARGUMENTS:
$this->stopwatch->start('controller','section');
break;
case KernelEvents::RESPONSE:
$token =$event->getResponse()->headers->get('X-Debug-Token');
$this->stopwatch->stopSection($token);
break;
case KernelEvents::TERMINATE:
// In the special case described in the `preDispatch` method above, the `$token` section
// does not exist, then closing it throws an exception which must be caught.
$token =$event->getResponse()->headers->get('X-Debug-Token');
try {
$this->stopwatch->stopSection($token);
}catch (\LogicException$e) {
}
break;
}
}
it should be OK and expected.

@nicolas-grekas
Copy link
Member

Thank you@jderusse.

@nicolas-grekasnicolas-grekas merged commit3830a9e intosymfony:3.4Dec 1, 2018
nicolas-grekas added a commit that referenced this pull requestDec 1, 2018
…bleEventDispatcher (jderusse)This PR was merged into the 3.4 branch.Discussion----------[EventDispatcher] Fix eventListener wrapper loop in TraceableEventDispatcher| Q             | A| ------------- | ---| Branch?       | 3.4| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | none| License       | MIT| Doc PR        | naThe `TracableEventDispatcher` wrap decorate (in the method `preProcess`) each listeners in a `WrappedListener` before delegating the dispatch to the real dispatcher, then remove the wrapper (in the method `postProcess`.But, if a listener triggers an exception, the `postProcess` method is not called, and the wrapper in not removed.If the same event is triggered a second time, the listeners will be decorated twice, etc, etc..This is an issue with php-pm where the same event is triggered hundred of times within the same process.This PR moves the `postProcess` in a finally block in order to be called even if an exception in thrown.Commits-------3830a9e Fix wrapped loop of event listener
This was referencedDec 6, 2018
@jderussejderusse deleted the fix-wrap-loop branchAugust 2, 2019 12:16
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+1 more reviewer

@ro0NLro0NLro0NL approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

4 participants

@jderusse@ro0NL@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp