In Index::__sleep() we unset all the index properties containing loaded plugins/field objects/entities to just keep the underlying properties. (We also unset the $cache property, which should actually have been removed from the code already – it's not used anywhere anymore.)
This is left over from before #2638116: Clean up caching of Index class method results (especially fields), where those properties were indeed just used for caching purposes and unsetting them had no effect.
Now, however, these properties are actually representing the index's current state, which should be saved by calling save() – if we just unset them, we potentially discard changes.
The proper handling here, I think, would be to do almost the same as in preSave() – i.e., write all the information from those objects back to the stored properties. When we then unset the object-valued properties, the changes will automatically be picked up again the next time the objects are loaded.
Probably we should just refactor preSave() to use a helper method and then use that in __sleep(), too.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 2727697-3--changed_serialized_index.patch | 6.26 KB | drunken monkey |
| #3 | 2727697-3--changed_serialized_index--tests_only.patch | 2.76 KB | drunken monkey |
Comments
Comment #2
drunken monkeyComment #3
drunken monkeyThis seems to resolve the problem and contains tests to prove it. Had to move the entity serialization test case to the kernel tests, but then it worked pretty smoothly.
This issue, by the way, also blocks #2640982: Fix "unsaved changes" code in the new Fields UI.
Comment #5
drunken monkeyComment #6
borisson_Comment #8
drunken monkeyThanks for reviewing!
Committed.