Skip to content

[DoctrineBridge] Don't reinit managers when they are proxied as ghost objects #46443

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

Merged
merged 1 commit into from
May 27, 2022

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented May 24, 2022

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

Paving the way to #35345

Interface GhostObjectInterface extends LazyLoadingInterface but breaks LSP because setProxyInitializer() takes another kind of closure as argument.

This won't solve #35216 since resetting a closed entity manager won't happen anymore if we start to use ghost object proxies. But at least this code won't explode.

/cc @ostrolucky any idea what we could put inside the added "if" to solve #35216? Would you be up to submit a PR doing that, branch 6.2 I guess since that'd be a new feature?

@ostrolucky
Copy link
Contributor

I don't know, sorry.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented May 24, 2022

OK, let's go with doctrine/DoctrineBundle#1528 for now

@stof
Copy link
Member

stof commented May 24, 2022

To me, the best solution for that would be to implement EntityManager::reset, that would recreate a UnitOfWork and reopen the EntityManager, instead of having to replace the EntityManager instance itself. This way, an EntityManager could be reset safely in a long running process like a queue consumer, even in case an exception happens when handling one message.
This would remove the need to use a proxy for the EntityManager (which was just a hacky way of making the EntityManager compatible with such use case).

@nicolas-grekas
Copy link
Member Author

What this mean @stof is that we cannot implement #35345 until ORM figured out a proper way to reset its state. Did I get you correctly?

@nicolas-grekas
Copy link
Member Author

I updated the PR to throw instead of ignoring. This shouldn't happen in practice since we don't generate ghost object proxies, but let's merge as a defensive measure.

@fabpot
Copy link
Member

fabpot commented May 27, 2022

Thank you @nicolas-grekas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants