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

[3.4.21 -> 3.4.22] Entities are detached from UnitOfWork #30240

Closed
jifer opened this issue Feb 14, 2019 · 2 comments
Closed

[3.4.21 -> 3.4.22] Entities are detached from UnitOfWork #30240

jifer opened this issue Feb 14, 2019 · 2 comments

Comments

@jifer
Copy link

jifer commented Feb 14, 2019

Symfony version(s) affected: 3.4.22

Description

A new entity was found through the relationship 'XXX#hcspData' that was not configured to cascade persist operations for entity: HCSPData@0000000023d966fc0000000028e438d7. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @manytoone(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'HCSPData#__toString()' to get a clue.

How to reproduce
HCSPData is fetched in service, this service is used in Subscriber pinned with Doctrine prePersist.
It was like that since I remember.
Updating Symfony version resulted in above error. Lowering version to .21 and everything works again.
Doctrine package is the same, so I believe this is not Doctrine problem.

For 3.4.21
$entityManager->contains($documentEntity) // true
EntityManager { #540 // where HCSPData is fetched
EntityManager { #540 // where XXX is flushed

For 3.4.22
$entityManager->contains($documentEntity) // false
EntityManager { #540 // where HCSPData is fetched
EntityManager { #559 // where XXX is flushed

What i found - EntityManager fetching HCSPData and EntityManager creating new entity in 3.4.21 is the same object, but in 3.4.22 they are not. You had to made change that is breaking DI object injecting. Both service & subscriber are fetching EM same way: public function __construct(EntityManagerInterface $entityManager)

After some digging I found this:

b3e17d2
Reverting changes from this commit done by @mmarynich makes everything work again.

@ro0NL
Copy link
Contributor

ro0NL commented Feb 14, 2019

see #30091 :}

@xabbuh
Copy link
Member

xabbuh commented Feb 14, 2019

Thank you for reporting, closing here as a duplicate of #30091.

@xabbuh xabbuh closed this as completed Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants