From 5bcaf27b05c4a07f06621199600fec32941c3465 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 6 Feb 2014 17:31:19 +0000 Subject: [PATCH] Issue #2190421 by amateescu: Fix some services that shouldn't be serialized. --- core/lib/Drupal/Core/Entity/ContentEntityBase.php | 4 ++++ core/lib/Drupal/Core/Entity/Entity.php | 10 ++++++++++ .../lib/Drupal/comment/CommentFormController.php | 7 +++++++ 3 files changed, 21 insertions(+) diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index c7f4275d7ce1..61481aff7612 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -338,6 +338,10 @@ public function __sleep() { $this->fields = array(); $this->fieldDefinitions = NULL; $this->clearTranslationCache(); + + // Don't serialize the url generator. + $this->urlGenerator = NULL; + return array_keys(get_object_vars($this)); } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 714aeeb7e11b..573d2d89b4ca 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -394,4 +394,14 @@ protected function urlGenerator() { return $this->urlGenerator; } + /** + * {@inheritdoc} + */ + public function __sleep() { + // Don't serialize the url generator. + $this->urlGenerator = NULL; + + return array_keys(get_object_vars($this)); + } + } diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index 6fde86c5ad6e..322d18a475ef 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -30,6 +30,13 @@ class CommentFormController extends ContentEntityFormController { */ protected $fieldInfo; + /** + * The current user. + * + * @var \Drupal\Core\Session\AccountInterface + */ + protected $currentUser; + /** * {@inheritdoc} */ -- GitLab