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
Child entity not retrieved from array cache #7969
Comments
Hi all, just checking to see if you had a chance to look at this since? Do you think it might be a bug? |
It was already labelled as a bug. Do you feel like you want to try to fix it in a pull request? |
Sure, let me see what I can do, thanks. |
PR: #8009 |
New PR against 2.7 #8023 |
Fixed by #8023 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
BC Break | no
Version | 2.7.0
Summary
Entity which is extended from a base class is not retrieved from array cache when using the second level cache.
ZF3 application.
Current behavior
Base class is abstract, with extending class as a child, using single table inheritance and second level cache.
When retrieving the child class using the findBy repository method, calls subsequent to the first one are not found in the cache. The entity is fetched from the database each time.
It looks to me like the entity is put into the cache with a key which is based on its child name but retrieval is attempted using the base class name.
How to reproduce
Entity definitions:
Base class:
Child class. Here the cache usage is set:
Doctrine configuration:
Calling fetch several times leads to a new db call each time (this is BaseChild repo):
Query log:
During debugging, I see that the entity is put into the array cache after the first call to the repository with the following key:
DoctrineModule:gts_base_entity_basechild[gts_base_entity_basechild_gts.base.entity.basechild_1][1]
But when retrieving the following key is used to find the entry:
DoctrineModule:gts_base_entity_basechild[gts_base_entity_basechild_gts.base.entity.base_1][1]
The reason for this is that in Doctrine\ORM\Cache\DefaultQueryCache::put (line 284) the cache key comes from the found entity however the key to retrieve comes from the root entity name in Doctrine\ORM\Cache\DefaultQueryCache::get (line 121).
Expected behavior
The second call to the repository should get the entity from the cache instead of making another query on the DB.
Of course it's possible that I'm missing some configuration and this may be expected as I have it configured - in which case any guidance regarding the configuration would be much appreciated.
This works as I would expect on any entity which does not have a base class.
The text was updated successfully, but these errors were encountered: