- Issue created by @marttir
- Merge request !93#3542448: Only compare field list item serialized data by common keys → (Open) created by Unnamed author
Quick patch. Probably doesn't work right if items in a multi-value field are added/removed.
- First commit to issue fork.
- 🇬🇧United Kingdom scott_euser
Thanks for the contribution! This sounds like it might be better as a update hook instead? Though I have not looked deeply at the cause.
For now I rebased latest into your MR since tests past on latest at the moment - 🇬🇧United Kingdom scott_euser
Will set to Needs Work per your comment in #3 in any case, but my guess is update hook is probably the way to go instead
Thinking about this further, I think the comparison does work for multi-value fields, since what's being compared is the entire field value at once, and not e.g. pairs of items. So e.g. adding new field items, removing some, or changing the order would still be detected as unequal even before the code hits the part where it checks the serialized data.
There are some reasons to favor changing the comparison over adding an update hook:
- An update hook needs to update field values on entity revisions – the comparison works on any revision
- An update hook needs to look at nodes, paragraphs and possibly also other entities – paragraphs would need to be done conditionally, but is updating arbitrary entities feasible?
- A separate update hook needs to be written every time a field setting is added/changed/removed
- If there is a lot of content using viewreference, the update could take a long time
So going the update hook route would increase the maintenance burden and potentially slow down deployments where the update runs. Also, there would still be the possibility of forgetting to create the hook and ending up in the same situation again.