dev/core#1984 fix custom fields sometimes missing from profiles #25321
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.
Overview
We were finding that custom fields were missing from profiles from time to time. See Sometimes Custom fields missing on profile
Before
Profiles would be missing their custom fields even if the user had access to them.
After
Profiles are now available to users, even if a less privileged user was the first one to access the profile after a cache refresh.
Technical Details
The list of custom fields for a profile is held in a cache created when the profile is first accessed after the cache has expired. Before this change that cache was generic to all users,, so it only held the fields visible to the first user accessing the profile after the cache refresh. If that user did not have access to the fields, they were not in the cache and subsequent users couldn't see them. By adding the user ID to the cache key, it means that each user creates their own cache, so they can see the fields to which they have access.
Comments
Anything else you would like the reviewer to note
It is a very simple change, simply adding the user id to the cache key used to hold the custom field information.