-
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 #6284 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
#6640
#6217 #6284 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
#6640
Conversation
…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
/* @var $found GH6217FetchedEntity[] */ | ||
$found = $repository->findBy($filters); | ||
|
||
$this->assertCount(1, $found); |
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.
self::
// | ||
// We need to unwrap those associations into proxy references, | ||
// since we don't have actual data for them except for identifiers. | ||
if ($unCachedAssociationData instanceof AssociationCacheEntry) { |
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.
It makes sense IMO, but I feel like we could do that conversion while iterating $entry['associations']
in https://github.com/doctrine/doctrine2/pull/6640/files#diff-c5343cb0b202102a59de56dfdcb8ee47R147 to avoid looping over the entire object data.
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.
$entry['associations']
does not contain the keys we're iterating upon here.
I considered using an accumulator of already processed keys, but since these are usually about associations, and the number of fields and associations is (typically) < 10 on any entity, looping is actually faster than aggregating the keys and excluding them here.
🚢 |
Fixes #6217
Fixes #6284
This is a proper version of #6284, fixing the deeper problem.
Basically, what is happening is that you have a L2 cached entity class like following:
And a DQL query like following:
The L2 cache for
A.c
won't have any information to cache, but it will still contain the identifier forA.c
. This means that for that association, aAssociationCacheEntry
exists anyway, but no definition in theQueryCacheEntry
on how to process it.I also tried fixing the problem on the other side (where the
QueryCacheEntry
is produced, rather than consumed), but overfitting it when no association data is actually available causes emptyAssociationCacheEntry
objects to be hydrated into empty entities (really bad!).This is just a shotgun patch to fix the problem by iterating over all possible association fields, so if you have any better ideas, please do let me know.