From e0628086af98c0110fdd0e8f24ec95fb1adc1d65 Mon Sep 17 00:00:00 2001 From: sun Date: Sun, 20 Jul 2014 20:55:13 +0200 Subject: [PATCH] Issue #2304461 by sun: Fixed DependencySerializationTrait breaks sans container. --- .../DependencyInjection/DependencySerializationTrait.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php index cb6a27d04c4a..9de7e71b9412 100644 --- a/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php +++ b/core/lib/Drupal/Core/DependencyInjection/DependencySerializationTrait.php @@ -49,9 +49,10 @@ public function __sleep() { * {@inheritdoc} */ public function __wakeup() { - $container = \Drupal::getContainer(); - foreach ($this->_serviceIds as $key => $service_id) { - $this->$key = $container->get($service_id); + if ($container = \Drupal::getContainer()) { + foreach ($this->_serviceIds as $key => $service_id) { + $this->$key = $container->get($service_id); + } } $this->_serviceIds = array(); }