-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#6217 when hydrating an entity with a composite primary key that is both an EAGER
and a LAZY
association and also cached, the DefaultQueryCache
tries to pass L2 cache implementation detail objects to the UnitOfWork
#6284
Conversation
@lcobucci if you merge this one, can you please check if the test can be moved to a smaller SUT test? |
6731689
to
7509c16
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gadelkareem thanks for the patch!
@Ocramius I've managed to reduce the SUT and saw that the problem ONLY happens when the fetch mode is EAGER
.
I've rebased it, removed some unrelated CS fixes and applied the same logic here.
@Ocramius although it LGTM would be nice to have your eyes too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ouch, forgot to send in this review :-\
@@ -738,6 +739,15 @@ public function getIdentifierValues($entity) | |||
return [$id => $value]; | |||
} | |||
|
|||
private function getIndentifierValue($entity, $id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docblock needed. id
probably needs a type-hint too, if we target 2.6 only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that $entity
can both be an entity and a cache entry is quite bothersome... Why was this choice made?
* @Entity | ||
* @Cache(usage="NONSTRICT_READ_WRITE") | ||
*/ | ||
class GH6217UserProfile |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you rename this to something like GH6217EntityWith3IdentityFieldsThroughAssociation
or such? I think that expresses intent much better. (yes, if you have a better name, please use that :-))
Same applies to the other entities.
* @Id | ||
* @Cache("NONSTRICT_READ_WRITE") | ||
* @ManyToOne(targetEntity="GH6217Profile", fetch="EAGER") | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No join column here?
* @Id | ||
* @Cache("NONSTRICT_READ_WRITE") | ||
* @ManyToOne(targetEntity="GH6217Category", fetch="EAGER") | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No join column here?
@@ -0,0 +1,162 @@ | |||
<?php | |||
namespace Doctrine\Tests\Functional\Ticket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a strict types declaration, since you are being quite strict about API usage in the test?
Re-iterating this: I don't think that classmetadata should ever interact with an |
I checked this patch locally, and the bug is fixed on the wrong end here: the |
EAGER
and a LAZY
association and also cached, the DefaultQueryCache
tries to pass L2 cache implementation detail objectsto the UnitOfWork
EAGER
and a LAZY
association and also cached, the DefaultQueryCache
tries to pass L2 cache implementation detail objectsto the UnitOfWork
EAGER
and a LAZY
association and also cached, the DefaultQueryCache
tries to pass L2 cache implementation detail objects to the UnitOfWork
…ry should never ever reach metadata
…ching issue. We are not hydrating some of the cached association data into entities due to keys missing in the cache association definition. Since this is an extreme edge case that is just a mismatch between db and cache, a detailed explanation was provided in the fix snippet as well
…id fix that was actually fixing the symptom
@gadelkareem please check #6640 and verify it against your codebase. |
@Ocramius thanks for the fix and sorry for having no time to help |
I recreated the branch for #6217 which forced closing to PR so I am submitting this as a new PR.
DESC: Handle AssociationCacheEntry identifier
Fixes Notice: Undefined property: Doctrine\ORM\Cache\AssociationCacheEntry::$id when retrieving an associated entity from a Composite primary key