diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index ff48437..6c2a700 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -366,6 +366,7 @@ public function preSave(EntityStorageInterface $storage) { * {@inheritdoc} */ public function __sleep() { + $keys_to_unset = []; if ($this instanceof EntityWithPluginCollectionInterface) { $vars = get_object_vars($this); // Any changes to the plugin configuration must be saved to the entity's @@ -374,12 +375,16 @@ public function __sleep() { $this->set($plugin_config_key, $plugin_collection->getConfiguration()); foreach ($vars as $key => $value) { if ($plugin_collection === $value) { - unset($vars[$key]); + $keys_to_unset[] = $key; } } } } - return parent::__sleep(); + $vars = parent::__sleep(); + foreach ($keys_to_unset as $key) { + unset($vars[array_search($key, $vars)]); + } + return $vars; } /**