Clear member cache by older user name when member user name is updated (13)#19672
Merged
nikolajlauridsen merged 2 commits intov13/devfrom Jul 7, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that when a member’s username is updated, any cached entries under the old username are also purged by capturing and propagating the previous username.
- Capture the old username in
AdditionalDataon member save - Extend the cache refresher payload to include
PreviousUsernameand clear both old and new keys - Introduce constants for the additional-data keys and update related handlers and extensions
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Umbraco.Core/Services/MemberService.cs | Capture previous username before save and populate AdditionalData |
| src/Umbraco.Core/Models/MemberGroup.cs | Replace literal "previousName" with a constant key |
| src/Umbraco.Core/Handlers/PublicAccessHandler.cs | Use constant key to detect and rename by previous member-group name |
| src/Umbraco.Core/Constants-Entities.cs | Define MemberPreviousUserName and MemberGroupPreviousName constants |
| src/Umbraco.Core/Cache/Refreshers/Implement/MemberCacheRefresher.cs | Add PreviousUsername to payload and clear cache by old name |
| src/Umbraco.Core/Cache/DistributedCacheExtensions.cs | Refactor to build payloads with PreviousUsername |
Comments suppressed due to low confidence (1)
src/Umbraco.Core/Cache/DistributedCacheExtensions.cs:175
- Add unit tests for
GetPayloadsand the cache refresher to verify thatPreviousUsernameis correctly populated and that cache entries are cleared for both the old and new usernames.
private static IEnumerable<MemberCacheRefresher.JsonPayload> GetPayloads(IEnumerable<IMember> members, bool removed)
1 task
This was referenced Dec 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prerequisites
Resolves #19618 for Umbraco 13
Description
The linked issue discusses the problem where updating a user in the backoffice to change the user name still leaves the member cached and retrievable by the old user name.
This PR uses the
AdditionalDatacollection available on entities to provide the previous user name to the cache refresher, so it can clear by the old user name as well as the new.I've also added a constant for the
AdditionalDatakey and used it for one other instance.Testing
With code like the following, retrieve a member by the user name:
Update the member's user name in the backoffice. Before the PR you will see the member is still found, but after these changes are applied, it should not be.