diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index 4963f77..9b840e0 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -2289,9 +2289,8 @@ public function calculateDependencies() { * {@inheritdoc} */ public function serialize() { - $storage = $this->storage instanceof ViewUI ? $this->storage : $this->storage->id(); return serialize([ - $storage, + $this->storage->id(), $this->current_display, $this->args, $this->current_page, @@ -2300,6 +2299,7 @@ public function serialize() { $this->exposed_data, $this->dom_id, $this->executed, + $this->storage instanceof ViewUI ? $this->storage : NULL, ]); } @@ -2307,12 +2307,16 @@ public function serialize() { * {@inheritdoc} */ public function unserialize($serialized) { - list($storage, $current_display, $args, $current_page, $exposed_input, $exposed_raw_input, $exposed_data, $dom_id, $executed) = unserialize($serialized); + list($view_id, $current_display, $args, $current_page, $exposed_input, $exposed_raw_input, $exposed_data, $dom_id, $executed, $view_ui) = unserialize($serialized); $this->setRequest(\Drupal::request()); $this->user = \Drupal::currentUser(); - $this->storage = is_object($storage) ? $storage : \Drupal::entityManager()->getStorage('view')->load($storage); + $this->storage = \Drupal::entityManager()->getStorage('view')->load($view_id); + if ($view_ui instanceof ViewUI) { + $view_ui->setStorage($this->storage); + $this->storage = $view_ui; + } $this->setDisplay($current_display); $this->setArguments($args); diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index 3b5351b..559b496 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -179,6 +179,19 @@ public function __construct(ViewEntityInterface $storage, ViewExecutable $execut } /** + * Sets the actual storage object. + * + * On cases like __unserialize, you want to let storage point to the right + * object. + * + * @param \Drupal\views\ViewEntityInterface $storage + * The view storage. + */ + public function setStorage(ViewEntityInterface $storage) { + $this->storage = $storage; + } + + /** * Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::get(). */ public function get($property_name, $langcode = NULL) {