Skip to content

fix: skip empty object write for untouched localized fields in mergeLocalizedData#16772

Open
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:fix/16649-merge-localized-empty-object
Open

fix: skip empty object write for untouched localized fields in mergeLocalizedData#16772
deepshekhardas wants to merge 1 commit into
payloadcms:mainfrom
deepshekhardas:fix/16649-merge-localized-empty-object

Conversation

@deepshekhardas
Copy link
Copy Markdown
Contributor

@deepshekhardas deepshekhardas commented May 28, 2026

Description

When \mergeLocalizedData\ encounters untouched localized fields (fields that haven't been modified), it was writing empty objects {}\ into the database instead of skipping them entirely. This caused data loss in specific scenarios where partial updates were performed on localized documents.

Root Cause

The \mergeLocalizedData\ utility in the payload core was not checking if the incoming value for a localized field was an empty object before proceeding with the write. An empty object {}\ vs \undefined/null makes a difference in how the database handles the field - empty objects overwrite existing localized data.

Fix

Added a guard to skip writing when the incoming value for a localized field is an empty object {}. This ensures untouched fields retain their existing values.

Note

This PR was split from an earlier combined PR. The related fixes are now in separate PRs:

Type of change

  • Bug fix (non-breaking change which fixes an issue)

@deepshekhardas deepshekhardas force-pushed the fix/16649-merge-localized-empty-object branch from b70fcad to d1e7a4f Compare June 5, 2026 05:14
@deepshekhardas deepshekhardas force-pushed the fix/16649-merge-localized-empty-object branch from d1e7a4f to b738a4a Compare June 5, 2026 05:15
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.

1 participant