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.

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Issue tags: +Release blocker
drunken monkey’s picture

This 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.

The last submitted patch, 3: 2727697-3--changed_serialized_index--tests_only.patch, failed testing.

drunken monkey’s picture

Issue tags: -Needs tests
borisson_’s picture

Status: Needs review » Reviewed & tested by the community

  • drunken monkey committed adb6ac8 on 8.x-1.x
    Issue #2727697 by drunken monkey, borisson_: Fixed serialization of...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for reviewing!
Committed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.