Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Invalid
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: ORM
-
Security Level: All
-
Labels:None
Description
Consider class A having a many-to-one relationship with B. In the database A's b_id column is zero or references a row of B that has been deleted.
When using lazy-loading, $a->getB()>getName() will throw EntityNotFoundException. $a>getB() will not be NULL, but rather a proxy (the b_id column was not NULL). So, to safely use $a->getB()->getName() in a view, you have to both wrap it in a try block and check for null (for "Fatal error: Call to a member function") in the view.
That situation is really tricky because Doctrine can't know B is NULL until the proxy's __load() is called. It would then need to convert the Proxy object to NULL and have all the calling functions handle that gracefully.
So what I'd really like is some reasonable way to convert invalid relationships to NULL without bloating every traversal call. Lazy loading makes handling invalid relationships inside the model very difficult because of __load() timing.
This is a major issue for us because potentially every traversal call in our application could trigger this problem.
Activity
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Invalid [ 6 ] |
| Workflow | jira [ 13747 ] | jira-feedback [ 15366 ] |
| Workflow | jira-feedback [ 15366 ] | jira-feedback2 [ 17230 ] |
| Workflow | jira-feedback2 [ 17230 ] | jira-feedback3 [ 19486 ] |
- Request to http://www.doctrine-project.org/fisheye/ failed: Error in remote call to 'FishEye 0 (http://www.doctrine-project.org/fisheye/)' (http://www.doctrine-project.org/fisheye) [AbstractRestCommand{path='/rest-service-fe/search-v1/crossRepositoryQuery', params={query=DDC-1851, expand=changesets[-21:-1].revisions[0:29],reviews}, methodType=GET}] : Received status code 503 (Service Temporarily Unavailable)
Don't really get your point right now: you have an inconsistent object graph and are trying to traverse it through relations? This is exactly the use case for foreign keys and cascading at db level, while traversing the graph through your getters and properties is completely up to you...
I don't think it is anything the ORM should handle for you, as you have to be aware of your entities being basically broken by the schema itself.