Platform param in the connection params results in not evicting cache entries #8890
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Query code tries to repeat the logic of the creation of query result cache keys, therefore it depends on that logic.
This leads to the bug presented in the PR, namely:
Doctrine\DBAL\Connection::executeCacheQuery() unsets the platform param before it creates the query result cache key:
However, Doctrine\ORM\Query::evictResultSetCache() doesn't unset the platform param when creating the query result cache key.
Therefore, when the platform param is present, the cached results are not being evicted from the cache and the Doctrine\Test\ORM\Query\QueryTest::testResultCacheEviction() test fails as the old result is still retrieved from the cache.
As an ad hoc solution we could unset the platform param as in Doctrine\DBAL\Connection::executeCacheQuery(), but it doesn't solve the architectural issue which results from breaking the Single Responsibility Principle and coupling the two modules.
Should the query result cache in that form exist at all? Shouldn't it be like in Hibernate where the query result cache is connected with the second level cache? Actually, what is called "query result caching" in Hibernated is already implemented in Doctrine (it is query caching in second level caching).