-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Do not use First Class Callable Syntax for listeners #46260
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It looks like you unchecked the "Allow edits from maintainer" box. That is fine, but please note that if you have multiple commits, you'll need to squash your commits into one before this can be merged. Or, you can check the "Allow edits from maintainers" box and the maintainer can squash for you. Cheers! Carsonbot |
Also it seems that CI is broken:
and so on. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I don't think this is the patch we want to merge. Instead, remove listener should be able to work with first-class callables. I'm going to submit a PR doing so, so that we can discuss about it.
See #46262 |
Closing in favor of #46262 which reuses the test cases you contributed. Thank you. |
…class callable syntax (javer) This PR was merged into the 4.4 branch. Discussion ---------- [EventDispatcher] Fix removing listeners when using first-class callable syntax | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #46260 | License | MIT | Doc PR | - Closures should be compared using non-strict comparison to account for the first-class callable syntax. See https://github.com/php/php-src/blob/9a90bd705483004c2ef408ee9e9bb0902beade3f/Zend/zend_closures.c#L387-L423 Commits ------- df4c003 [EventDispatcher] Fix removing listeners when using first-class callable syntax
This PR fixes usage of First Class Callable Syntax for registering listeners which are intended to be unregistered later.
I'm targeting 6.1 branch because the issue was introduced only in this branch via b0217c6
The reason of this change is clear from the following example:
In other words, it's not safe to use First Class Callable Syntax in the cases when we need to refer to the same function to remove it from somewhere, because each
method(...)
returns a new function.