ObjectHydrator and ArrayHydrator incorrectly hydrate fields of child classes in a JTI when a field name collides #5430

Closed
opened 2026-01-22 15:07:36 +01:00 by admin · 2 comments
Owner

Originally created by @fullbl on GitHub (Feb 24, 2017).

Originally assigned to: @Ocramius on GitHub.

Hi,

I have an entity named A, which is extended on multi table inheritance by B and C.

Both have a property called $user, which is a simple string on B and a simple_array on C.

If I load the object by query builder with the repository of A and get an object of type B, I could get an empty array, even if I'm expecting a string. This is because AbstractHydrator is setting first non null value from all the joined tabled after translating it into php. Null is converted into array in SimpleArrayType convertToPHPValue function.

An easy solution could be to check for the value to be null BEFORE assigning it, as for #5989

Originally created by @fullbl on GitHub (Feb 24, 2017). Originally assigned to: @Ocramius on GitHub. Hi, I have an entity named A, which is extended on multi table inheritance by B and C. Both have a property called $user, which is a simple string on B and a simple_array on C. If I load the object by query builder with the repository of A and get an object of type B, I could get an empty array, even if I'm expecting a string. This is because AbstractHydrator is setting first non null value from all the joined tabled after translating it into php. Null is converted into array in SimpleArrayType convertToPHPValue function. An easy solution could be to check for the value to be null BEFORE assigning it, as for #5989
admin added the BugDuplicate labels 2026-01-22 15:07:36 +01:00
admin closed this issue 2026-01-22 15:07:37 +01:00
Author
Owner

@dengm129 commented on GitHub (Jun 21, 2017):

#5989

@dengm129 commented on GitHub (Jun 21, 2017): #5989
Author
Owner

@Ocramius commented on GitHub (Aug 19, 2017):

Handled in #6304

@Ocramius commented on GitHub (Aug 19, 2017): Handled in #6304
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5430