[4.x] Use closest origin that has field localized to determine if a field can be forgotten in makeModelFromContract method of Entry#587
Merged
Conversation
Contributor
|
Would you please add a test showing that this change fixes the incorrect behaviour? |
Contributor
Author
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 😅 |
…eld can be forgotten in `makeModelFromContract` method of `Entry`
777627b to
a460649
Compare
Contributor
Author
|
@ryanmitchell I have added a test that should reproduce the issue I was experiencing. Let me know if you need any additional changes / information! |
Contributor
|
Thank you |
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.
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.