[PR #5812] Use ResultSetMapper in cache key so schema changes invalidate cache #9737

Closed
opened 2026-01-22 16:05:16 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/5812

State: closed
Merged: No


This fixes a long standing issue we've been facing with schema changes and result caching.
When new code is deployed that contains a scheme change any queries hitting the result cache return null values because of this check. Adding or removing any fields make the keys defined by the ResultSetMapper different then the keys stored in the cache. As a result the ObjectHydrator can't find the id so it return null for each which makes for some confusing errors.

This change adds a hash of the current ResultSetMapper to the real key effectively invalidating the cache on any schema changes for any entity in the query.

REQUIRES:
https://github.com/doctrine/dbal/pull/2383

**Original Pull Request:** https://github.com/doctrine/orm/pull/5812 **State:** closed **Merged:** No --- This fixes a long standing issue we've been facing with schema changes and result caching. When new code is deployed that contains a scheme change any queries hitting the result cache return null values because of [this check](https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php#L482). Adding or removing any fields make the keys defined by the ResultSetMapper different then the keys stored in the cache. As a result the ObjectHydrator can't find the id so it return null for each which makes for some confusing errors. This change adds a hash of the current ResultSetMapper to the real key effectively invalidating the cache on any schema changes for any entity in the query. REQUIRES: https://github.com/doctrine/dbal/pull/2383
admin added the pull-request label 2026-01-22 16:05:16 +01:00
admin closed this issue 2026-01-22 16:05:16 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#9737