mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-3687: Entities part of a hierarchy seem not to inherit SLC configuration from 'root' Entity #4531
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 @doctrinebot on GitHub (Apr 13, 2015).
Originally assigned to: @lcobucci on GitHub.
Jira issue originally created by user holtkamp:
When using the Second Level Cache on associations, the documentation states that "the target entity must also be marked as cacheable"
It seems that when this targetEntity is an (possibly abstract) 'root' Entity of an Entity hierarchy, all Entities of that hierarchy need to be marked as cacheable. I would expect that all Entities that are part of the Entity hierarchy, also inherit this cache configuration metadata of the root Entity...
Is this intended behavior?
For example, this does NOT work:
The generated error:
For example, this does DOES work
@doctrinebot commented on GitHub (Apr 13, 2015):
@doctrinebot commented on GitHub (Apr 13, 2015):
Comment created by @FabioBatSilva:
Hi [~holtkamp] All subclasses should already Inherit the cache configuration .
Can please attach your entities/mapping ?
@doctrinebot commented on GitHub (Apr 13, 2015):
Comment created by holtkamp:
Mm, you are right, the cache configuration seems to be inherited. General idea of my Mapping is at the end of this comment.
The error occurs after the cache has been filled (2nd request). The following CollectionCacheEntry is used to lookup the EntityEntries:
This results in a $entityEntries collection with one entry, (which is empty!) as retrieved from cache at:
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/DefaultCollectionHydrator.php#L84
Having a look at the actual content of the SLC cache shows that the entry exists, so the lookup goes wrong. It seems 'DefaultRegion::getMultiple()' contains a bug:
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php#L122
Should be
Since the $items array uses the same keys as the $keysToRetrieve array, filled at https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Cache/Region/DefaultRegion.php#L106
My mapping (pseudo-code)
@doctrinebot commented on GitHub (Apr 13, 2015):
Comment created by @FabioBatSilva:
Yes, it looks like a bug on DefaultRegion::getMultiple()
Can you try to write a failing test case or/and maybe send a PR ?
@doctrinebot commented on GitHub (Apr 13, 2015):
Comment created by holtkamp:
Mm, will try to find some time this week. Not very experienced in writing test cases though...
@doctrinebot commented on GitHub (Apr 13, 2015):
Comment created by @FabioBatSilva:
Cool,
Take a look at : SecondLevelCacheTest and let me know if you need help..
@doctrinebot commented on GitHub (Apr 13, 2015):
Comment created by holtkamp:
Ok, challenge accepted, got a test case running in this branch, I used:
It seems the way DefaultRegion::getMultiple() works is overcomplicated? Maybe just return the $items array as an end-result?
@doctrinebot commented on GitHub (Apr 13, 2015):
Comment created by @FabioBatSilva:
If you want to refactory it some how, that will be great..
DefaultRegion::getMultiple tries to check if all keys are found in the cache, and then maps it back to the original key
If any of then are missing it will return null which will trigger a new database query to reload the entries and repopulate the cache.
Overall you branch seems good, Can you send a PR please ?
@doctrinebot commented on GitHub (Apr 14, 2015):
Comment created by holtkamp:
Ok, I gave it a shot at https://github.com/doctrine/doctrine2/pull/1382, AFAIK the index of the resulting array can just be numeric, right?
@doctrinebot commented on GitHub (Apr 14, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1382] was labeled:
https://github.com/doctrine/doctrine2/pull/1382
@doctrinebot commented on GitHub (Apr 14, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1382] was assigned:
https://github.com/doctrine/doctrine2/pull/1382
@doctrinebot commented on GitHub (Apr 14, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1382] was merged:
https://github.com/doctrine/doctrine2/pull/1382
@doctrinebot commented on GitHub (Apr 15, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1382] was unassigned:
https://github.com/doctrine/doctrine2/pull/1382
@doctrinebot commented on GitHub (Apr 15, 2015):
Comment created by @doctrinebot:
A related Github Pull-Request [GH-1382] was assigned:
https://github.com/doctrine/doctrine2/pull/1382
@lcobucci commented on GitHub (Jan 20, 2017):
Fixed by #1382