phpcr-odm icon indicating copy to clipboard operation
phpcr-odm copied to clipboard

Children not persisted when created in doctrine event listener

Open dbu opened this issue 9 years ago • 1 comments

@petforsberg reported originally in https://github.com/doctrine/DoctrinePHPCRBundle/issues/179

Within my app, when I create an Article, app auto-generates a News for it. Both (Article and News) have their own children-nodes attached (always). The workflow looks like this:

  1. persist Article
  2. Doctrine EventListener - Article postPersist: create children, and set their Parent as Article
  3. Doctrine EventListener - Article postPersist: EventDispatcher -> generate News (creates new News document inside the other service)
  4. persist News (in the same service)
  5. Doctrine EventListener - News postPersist: create children, and set their Parent as News

Points 1-4 work well. But children persisted to another persisted Document - News - seem to be not persisted at all. I checked everything, it took me like 4 hours or so. Everything looks fine, objects are created, persisted, they exist... until I do flush. Then News children-elements disappear.

Do you know why does it happen?

Forgot to mention: when I create a bare News (not auto-generated in the nested Doctrine events), it is created without a problem, with its children.

dbu avatar Aug 10 '15 07:08 dbu

see https://github.com/doctrine/DoctrinePHPCRBundle/issues/179 for previous discussion

dbu avatar Aug 10 '15 07:08 dbu