Skip to content

[4.x] Use closest origin that has field localized to determine if a field can be forgotten in makeModelFromContract method of Entry#587

Merged
ryanmitchell merged 2 commits into
statamic:4.xfrom
Boefjim:bugfix/localized-entry-values
Jun 3, 2026
Merged

[4.x] Use closest origin that has field localized to determine if a field can be forgotten in makeModelFromContract method of Entry#587
ryanmitchell merged 2 commits into
statamic:4.xfrom
Boefjim:bugfix/localized-entry-values

Conversation

@Boefjim
Copy link
Copy Markdown
Contributor

@Boefjim Boefjim commented May 13, 2026

When working with localizations of localizations, the localized fields are not handled appropriately, specifically whenever a localization field is left empty it only checks the direct origin and sees null == null and thus it think it does not need to be localized (even though the origin that the value is then inherited from might not be null).

This change will make it so for each localized field, it will check the closest origin that has the field localized, ensuring that this is cascaded correctly.

While I personally need this fixed in the 4.x branch, it seems this issue also exists in the 5.x branch...should I make a separate PR for 5.x or how would it be best to approach this?
The method is slightly expanded in the new version, but the logic that determines which localized fields can be forgotten seems to be the same, and could thus likely receive the same patch.

@ryanmitchell
Copy link
Copy Markdown
Contributor

Would you please add a test showing that this change fixes the incorrect behaviour?

@Boefjim
Copy link
Copy Markdown
Contributor Author

Boefjim commented May 22, 2026

Would you please add a test showing that this change fixes the incorrect behaviour?

Yes, I will try to get a test written for this, although it might take some time, since I have only managed to reproduce this through the Statamic UI and I am unsure what methods are called through it in order to reproduce this through code 😅

@Boefjim Boefjim force-pushed the bugfix/localized-entry-values branch from 777627b to a460649 Compare June 2, 2026 14:25
@Boefjim
Copy link
Copy Markdown
Contributor Author

Boefjim commented Jun 2, 2026

@ryanmitchell I have added a test that should reproduce the issue I was experiencing.
I have also put the commit that adds the test before the fix, so it is easier to see it failing by simply checking out that commit (hence the force-push).

Let me know if you need any additional changes / information!

@ryanmitchell ryanmitchell merged commit 90c87ac into statamic:4.x Jun 3, 2026
0 of 21 checks passed
@ryanmitchell
Copy link
Copy Markdown
Contributor

Thank you

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.

2 participants