Skip to content

fix: fallback to previous value, or default, if field access is denied - #11544

Closed
SimonVreman wants to merge 1 commit into
payloadcms:mainfrom
SimonVreman:fix/field-access-erasing-data
Closed

SimonVreman wants to merge 1 commit into
payloadcms:mainfrom
SimonVreman:fix/field-access-erasing-data

Conversation

@SimonVreman

Copy link
Copy Markdown
Contributor

What?

#11543
Data is lost or validation fails when the user is not allowed to update the field, as the order in traverse fields was changed in #11433

How?

Fallback to previous data, then to default value and finally delete the field, to restore previous behavior while avoiding regression of the previous bug.

Closes #11543

@SimonVreman SimonVreman changed the title fix(core): fallback to previous value, or default, if field access is denied fix: fallback to previous value, or default, if field access is denied Mar 5, 2025
@SimonVreman

SimonVreman commented Mar 5, 2025 •

Copy link
Copy Markdown
Contributor Author

I also see an argument for fixing this in the adapter, not triggering an update for these fields in general, but that is more difficult to get right, and this is a pretty major bug.

That doesn't make sense, as the data loss isn't directly caused by the adapter updating fields it shouldn't, rather by hooks receiving an incorrect value.

@JarrodMFlesch

Copy link
Copy Markdown
Contributor

This PR fixes the issue and adds tests to prevent this from happening in the future. Again, thank you for reporting the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Field is set to null if the user does not have access

2 participants