Affects Version/s: Git Master
Fix Version/s: None
Security Level: All
Hi. I am just now trying to convert a PHP project from Symfony 2.0 to Symfony 2.1. Then I also upgraded to the latest version of Doctrine, and I run into a severe problem.
The application I am converting has two classes for users, one called "User" and the other called "UserName". They both inherit from "UserBase" and "UserName" is in fact an empty class that just inherit everything from "UserBase". Why do we have this setup? Because the "User" class is big and ugly with many dependencies form other tables in the database, and every time you load a "User" object it has to do a big join. And even then it has several collections that are lazy-loaded by Doctrine. In contrast "User Name" only contains name and e-mail, and is sufficient for most uses in the application.
It was not possible to let "UserBase" be this lightweight user object, because it had to be declared as a mapped superclass, and a mapped superclass cannot be an entity. It functioned very well to let a lot of ManyToOne relationships in other classes be to the "UserName" entity, because then it only had to join one table, and it was fast. The full functionality of the "User" class we only need a few places.
So, all was well and good, until I now got the task of porting the whole thing to the latest version of Symfony. What is wrong? I get the error message "Found entity of type User on association Object#Name, but expecting UserName". It is in the file UnitOfWork.php around line 740, and it makes my task impossible.
In some cases I got a "User" object instead of "UserName" object that is declared in the "targetEntity". And that should be ok, because they come from the same table, and I only want to save the userId on the other object, and all "User" and "UserName" objects are directly form the database and not altered when I try to persist that other object.
So, please, please, can you make the check a bit less restrictive? May be not just check if the entry is "instanceof" the "targetEntity", but allow it if the entity refers to the same table. Or only throw the exception if it is a new entity that needs to managed. Or make an annotation that makes it possible to switch this check off? I am a bit desperate here, because I really see no way around this. Thank you.
|Status||Open [ 1 ]||Closed [ 6 ]|
|Resolution||Invalid [ 6 ]|