Ticket #836 (closed defect: fixed)
Failure to hydrate multiple left-joined components if a previous set was empty
| Reported by: | AndySchmitt | Owned by: | zYne- |
|---|---|---|---|
| Priority: | major | Milestone: | 0.10.3 |
| Component: | Query/Hydration | Version: | 0.10.0 |
| Severity: | Keywords: | ||
| Cc: | Has Test: | ||
| Status: | Has Patch: |
Description (last modified by AndySchmitt) (diff)
This problem can be triggered by creating several classes with the following relationships (class content does not matter):
ClassA hasMany ClassB
ClassB hasOne ClassC
ClassA hasMany ClassD
ClassD hasOne ClassE
And then running a DQL query with the following: FROM ClassA a LEFT JOIN a.ClassB b LEFT JOIN b.ClassC c LEFT JOIN a.ClassD d LEFT JOIN d.ClassE e
If there are no rows in ClassB, but there are rows in ClassD, a.ClassB will have a count of 0 (which is expected), but a.ClassD won't even exist in the hydrated record!
This is because the foreach() loop in Hydrator::hydrateResultSet() does a break if there was no previous parent for a component. In my opinion, this should be a continue, so it can ignore the current component that has no parent, but continue to find additional components that may exist.
The attached patch should fix this behavior. Sorry, I have not run unit tests against this updated version as I'm on a deadline for another project. But the unit tests in my project, which heavily uses query/hydration, all work after running the modified library with this patch.