diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
index 8c0c376..6c2a700 100644
--- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -365,6 +365,31 @@ 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
+      // copy as well, then unset the plugin collection.
+      foreach ($this->getPluginCollections() as $plugin_config_key => $plugin_collection) {
+        $this->set($plugin_config_key, $plugin_collection->getConfiguration());
+        foreach ($vars as $key => $value) {
+          if ($plugin_collection === $value) {
+            $keys_to_unset[] = $key;
+          }
+        }
+      }
+    }
+    $vars = parent::__sleep();
+    foreach ($keys_to_unset as $key) {
+      unset($vars[array_search($key, $vars)]);
+    }
+    return $vars;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
   public function calculateDependencies() {
     // All dependencies should be recalculated on every save apart from enforced
     // dependencies. This ensures stale dependencies are never saved.
