Skip to content
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

Make manager registry resettable #1099

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Dec 17, 2019

Fixes #1083.

This also adds a dependency to the Symfony Service contracts to ensure we've got the ResettableInterface.

@alcaeus alcaeus added the Bug label Dec 17, 2019
@alcaeus alcaeus added this to the 1.12.3 milestone Dec 17, 2019
@alcaeus alcaeus self-assigned this Dec 17, 2019
@alcaeus alcaeus requested a review from greg0ire December 18, 2019 07:55
@alcaeus alcaeus force-pushed the reset-manager-registry branch from d798dee to be9794b Compare December 18, 2019 13:55
@alcaeus alcaeus merged commit 6a81d1c into doctrine:1.12.x Dec 18, 2019
@alcaeus alcaeus deleted the reset-manager-registry branch December 18, 2019 14:06

public function reset() : void
{
foreach ($this->getManagerNames() as $managerName) {
Copy link
Contributor

@alexander-schranz alexander-schranz Dec 18, 2019

Choose a reason for hiding this comment

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

@alcaeus My array looks like this in 1.12.3:

  ["default"]=>
  string(35) "doctrine.orm.default_entity_manager"

and ends so with:

Doctrine ORM Manager named "doctrine.orm.default_entity_manager" does not exist.

Exception.

any hint how this can happen?

Copy link
Contributor

Choose a reason for hiding this comment

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

the bin/console debug:container --parameter doctrine.entity_managers does also return it this way

Copy link
Member Author

Choose a reason for hiding this comment

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

See #1103.

@stof
Copy link
Member

stof commented Dec 18, 2019

should we force resetting the entity manager (which will unload all mapping metadata), or would clearing it be enough when it is still open (resetting is indeed necessary if the EM got closed by an error during the flush) ?

@hugochinchilla
Copy link

Since the inclusion of this PR in the master branch I'm getting this error when running my tests:

LogicException: Resetting a non-lazy manager service is not supported. Declare the "doctrine.orm.default_entity_manager" service as lazy.

@alcaeus
Copy link
Member Author

alcaeus commented Dec 19, 2019

@hugochinchilla can you try the latest 1.12.x branch and report back? That should fix your issue. I’ll merge up to 2.0.x later today.

@hugochinchilla
Copy link

@alcaeus I can confirm than cherrypicking #1108 on top o 2.0.5 fixes my issue.

Also requiring symfony/proxy-manager-bridge solves the issue, I don't know how it does it. I just tried the solution to a similar issue posted a year ago on StackOverflow.

I will lock to 2.0.2 until #1108 is merged on 2.0.x branch.

Thanks for your help.

@alcaeus
Copy link
Member Author

alcaeus commented Dec 19, 2019

Thanks for confirming! I've released 1.12.6 and 2.0.6 containing the fix.

The reason why installing the proxy-manager-bridge works is because that makes your entity managers lazy, which avoids the exception that you ran into before. With the release, this is fixed without having lazy entity managers.

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

Successfully merging this pull request may close these issues.

5 participants