Cache: Invalidate element GUID-keyed cache on delete (closes #22911)#22940
Conversation
|
Claude finished @AndyButland's task in 2m 28s —— View job PR ReviewTarget: Corrects the isolated cache invalidation key used when clearing a GUID-keyed element cache entry on delete. The old call used Suggestions
ApprovedThis looks good to be merged as-is. The two-line change is correct, precisely targeted, and directly mirrors the established pattern from |
There was a problem hiding this comment.
Pull request overview
Fixes stale element lookups by GUID after an element is deleted by ensuring the GUID-keyed repository cache entry is invalidated by ElementCacheRefresher, aligning element cache invalidation with the existing content/media pattern.
Changes:
- Update
ElementCacheRefresher.Refreshto clear GUID-keyed repository cache entries usingRepositoryCacheKeys.GetGuidKey<IElement>(...)(theuRepoGuid_prefix) instead of the int-key prefix helper.
Description
After moving an element to the recycle bin and emptying it,
IElementService.GetById(Guid key)still returned the element until the site was restarted.The
EntityByGuidReadRepositoryused by element/content/media repositories stores its entries with theuRepoGuid_prefix (viaRepositoryCacheKeys.GetGuidKey<T>).ContentCacheRefresherandMediaCacheRefresherwere updated to use that prefix when the GUID-keyed cache policy was introduced;ElementCacheRefresherwas missed and still cleared with the olduRepo_prefix (viaRepositoryCacheKeys.GetKey<T, TId>), so the GUID-keyed entry was never invalidated.The fix changes the GUID-key clearing in
ElementCacheRefresher.RefreshfromGetKey<IElement, Guid?>toGetGuidKey<IElement>, matching the pattern already used for documents and media.Fixes #22911
Testing
Automated
I wasn't successful getting an integration test running that reliably shows the error before the fix and the resolution afterward.
Manual
Add this temporary debug controller (not committed) and run the site:
Reproduction:
Expected response before the fix:
Expected response after the fix: