mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Undefined Property error in ObjectHydrator when using JOIN WITH #5478
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SirWaddles on GitHub (Mar 27, 2017).
Originally assigned to: @lcobucci on GitHub.
I have a pretty strange issue that I can't quite work out, I have a fix but it's affecting code from 8yrs ago which seems pretty stable.
I have a DQL query resembling
where a Base can have many Fruits of multiple types. The error I get when trying to run this query is just
Undefined property on AppBundle\Base::$dataFor some reason, the ObjectHydrator is trying to add the values retrieved from the database to the wrong entity. After doing some debugging, I found something a little odd in ObjectHydrator.php
It appears that it can only ever get a reference to the first object that there is a root alias to. After changing the second line to
$first = $this->resultPointers[$parentAlias];in a debug build, my problem is solved and although I didn't run through the unit tests (will do if it's a PR, but it seems more like I'm doing something wrong here) my application elsewhere works fine.I realise there is a limitation when it comes to downcasting in Doctrine (which is what I am trying to do) but it seems like this issue would have broader implications.
@lcobucci commented on GitHub (Mar 27, 2017):
This is a known limitation of the ORM when working with class table inheritance and might not be properly documented.
@SirWaddles would be nice if you could reproduce and implement a good (tested) solution for this on a PR.
@lcobucci commented on GitHub (May 2, 2017):
Fixed by #6367