Children not persisted when created in doctrine event listener
- Dominant language
- PHP
- Stars
- 181
- Forks
- 102
- PR merge metrics
- No merged PRs in 30d
Description
@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.
Contributor guide
Research direction
Start by reproducing the five-step Article and News event-listener workflow described in the issue, comparing it with creating a bare News. Trace the objects through the final flush and document why News children disappear; the issue names no files or tests, so identifying the relevant persistence lifecycle code will be part of the work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100