Skip to content

[1.x] fix(notifications): invalidate unread count cache on delete all#4391

Merged
imorland merged 1 commit into1.xfrom
im/fix-delete-notifications-cache-invalidation-1x
Feb 26, 2026
Merged

[1.x] fix(notifications): invalidate unread count cache on delete all#4391
imorland merged 1 commit into1.xfrom
im/fix-delete-notifications-cache-invalidation-1x

Conversation

@imorland
Copy link
Member

Regression of #4365

Port of #4390 (2.x fix) to 1.x.

#4365 added caching to getUnreadNotificationCount() and getNewNotificationCount() with active cache invalidation in ReadAllNotificationsHandler and ReadNotificationHandler. DeleteAllNotificationsHandler was missed.

Symptom

After clicking "Delete All" in the notifications dropdown, the notifications disappear from the list (optimistic update works) but the unread count badge reappears on the next page load and stays wrong for up to 5 minutes until the cache naturally expires.

Fix

Add resolve('cache.store')->forget() calls for both count keys after deletion, matching the pattern already used in ReadAllNotificationsHandler.

Test

Added a regression test that primes both cache keys with a stale value of 99, calls DELETE /api/notifications, and asserts both keys are null after the request.

Related

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

…ession of #4365)

#4365 added caching to getUnreadNotificationCount() and getNewNotificationCount()
and correctly invalidated the cache in ReadAllNotificationsHandler and
ReadNotificationHandler. DeleteAllNotificationsHandler was missed, so deleting
all notifications left the stale count in the cache for up to 5 minutes —
causing the notification badge to reappear after deletion until the cache
naturally expired.

Fix: call resolve('cache.store')->forget() on both count keys after deletion,
matching the pattern already used in ReadAllNotificationsHandler.

Also adds a regression test that primes the cache with a stale count, calls
DELETE /notifications, and asserts both cache keys are cleared.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imorland imorland requested a review from a team as a code owner February 26, 2026 10:34
@imorland imorland added this to the 1.8.14 milestone Feb 26, 2026
@imorland imorland force-pushed the im/fix-delete-notifications-cache-invalidation-1x branch from 9c534ff to 1dee5f7 Compare February 26, 2026 10:47
@imorland imorland merged commit b5a16e2 into 1.x Feb 26, 2026
759 of 816 checks passed
@imorland imorland deleted the im/fix-delete-notifications-cache-invalidation-1x branch February 26, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant