Problem/Motivation
Index::__sleep() builds its property list from get_object_vars($this) and never calls parent::__sleep(), so EntityBase::__sleep() never clears $typedData.
Since Drupal core #3574230: Use a weak reference for EntityBase::typedData, EntityBase::$typedData holds a WeakReference. Once getTypedData() has been called on an index, serialize() throws "Serialization of 'WeakReference' is not allowed". On core versions without that change, nothing crashes, but the typed data object is serialized along with the index.
Steps to reproduce
Load an index, call $index->getTypedData(), then serialize($index).
Proposed resolution
Build the property list from parent::__sleep() instead of get_object_vars($this). The existing unset() calls for the plugin instances stay as they are.
SerializationTest::testIndexSerialization() now calls getTypedData() before checking that no serialized property contains an object. It fails without the fix and passes with it.
Issue fork search_api-3644313
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
pcambra