-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Bridge\ProxyManager] Dont call __destruct() on non-instantiated services #23729
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
c366fc7
to
6fb67d5
Compare
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function getGenerator() : ProxyGeneratorInterface |
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.
You can't use feature from PHP 7 on branch that supports version 5.5
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.
fixed
6baa81f
to
b98fc0a
Compare
*/ | ||
class LazyLoadingValueHolderFactoryV1 extends BaseFactory | ||
{ | ||
private $generatorV1; |
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.
why does it have a different name here ? Except for the property name, the code is the same in v1 and V2.
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.
Because in v0.4, the property exists and is protected, thus can't be made private...
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.
we could just use a name available in both versions
b98fc0a
to
2d79ffa
Compare
Thank you @nicolas-grekas. |
…tiated services (nicolas-grekas) This PR was merged into the 2.7 branch. Discussion ---------- [Bridge\ProxyManager] Dont call __destruct() on non-instantiated services | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - While working on making #23678 green, I discovered that if a lazy service implements `__destruct`, then that service is not lazy anymore: it is created at destruct time. That behavior is documented at Ocramius/ProxyManager#258 (+related issues). While I may understand why this behavior is the default for ProxyManager, it does not fit our "lazy-services" use case to me. Typically, nobody wants a database connection to be created to destruct the uninitialized lazy-proxy. Blocks #23678 Commits ------- 2d79ffa [Bridge\ProxyManager] Dont call __destruct() on non-instantiated services
While working on making #23678 green, I discovered that if a lazy service implements
__destruct
, then that service is not lazy anymore: it is created at destruct time.That behavior is documented at Ocramius/ProxyManager#258 (+related issues).
While I may understand why this behavior is the default for ProxyManager, it does not fit our "lazy-services" use case to me. Typically, nobody wants a database connection to be created to destruct the uninitialized lazy-proxy.
Blocks #23678