diff --git a/core/modules/views/src/Entity/View.php b/core/modules/views/src/Entity/View.php index ecd541e..63d3ba1 100644 --- a/core/modules/views/src/Entity/View.php +++ b/core/modules/views/src/Entity/View.php @@ -433,4 +433,13 @@ public function isInstallable() { return (bool) \Drupal::service('views.views_data')->get($this->base_table); } + /** + * {@inheritdoc} + */ + public function __sleep() { + $keys = parent::__sleep(); + unset($keys[array_search('executable', $keys)]); + return $keys; + } + } diff --git a/core/modules/views/src/ViewExecutable.php b/core/modules/views/src/ViewExecutable.php index ddc0ca9..3d38a98 100644 --- a/core/modules/views/src/ViewExecutable.php +++ b/core/modules/views/src/ViewExecutable.php @@ -2290,7 +2290,7 @@ public function calculateDependencies() { */ public function serialize() { if ($this->storage instanceof ViewUI) { - $storage = clone $this->storage; + $storage = $this->storage; } else { $storage = $this->storage->id(); diff --git a/core/modules/views/tests/src/Unit/ViewExecutableTest.php b/core/modules/views/tests/src/Unit/ViewExecutableTest.php index 85b545c..51de164 100644 --- a/core/modules/views/tests/src/Unit/ViewExecutableTest.php +++ b/core/modules/views/tests/src/Unit/ViewExecutableTest.php @@ -465,4 +465,11 @@ protected function setupBaseViewAndDisplay() { return array($view, $display); } + /** + * Tests serialization of the ViewExecutable object. + */ + public function testSerialization() { + // @todo + } + } diff --git a/core/modules/views_ui/src/ViewUI.php b/core/modules/views_ui/src/ViewUI.php index b8b8074..6a41d9b 100644 --- a/core/modules/views_ui/src/ViewUI.php +++ b/core/modules/views_ui/src/ViewUI.php @@ -173,6 +173,10 @@ class ViewUI implements ViewEntityInterface { public function __construct(ViewEntityInterface $storage, ViewExecutable $executable = NULL) { $this->entityType = 'view'; $this->storage = $storage; + + if (isset($executable)) { + $this->executable = $executable; + } } /** @@ -898,14 +902,6 @@ public function __call($method, $args) { } /** - * Magic __clone behavior. - */ - public function __clone() { - $this->storage = clone $this->storage; - $this->executable = NULL; - } - - /** * {@inheritdoc} */ public function &getDisplay($display_id) { @@ -1288,4 +1284,11 @@ public function unsetThirdPartySetting($module, $key) { public function getThirdPartyProviders() { return $this->storage->getThirdPartyProviders(); } + + public function __sleep() { + $vars = get_object_vars($this); + unset($vars['executable']); + return array_keys($vars); + } + }