From 2ce81ab60660289296d3d90dfc7ab86dd825555d Mon Sep 17 00:00:00 2001
From: Benjamin Franzke <bfr@qbus.de>
Date: Wed, 13 May 2020 17:11:52 +0200
Subject: [PATCH] [BUGFIX] Fix serialization of ObjectManager

The PSR-11 container instance was not cleared upon serialization which
caused an exception when Closures in the container where tried to be
serialized.

__wakeup() does already contain code to reset the container instance,
therefore we only need to clear the entire object manager properties
in __sleep().

Releases: master
Resolves: #91398
Related: #88689
Change-Id: I58202752577b58cd882d13f471af1e045c9a4187
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64489
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Alexander Schnitzler <git@alexanderschnitzler.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Alexander Schnitzler <git@alexanderschnitzler.de>
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Susanne Moog <look@susi.dev>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
---
 typo3/sysext/extbase/Classes/Object/ObjectManager.php | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/typo3/sysext/extbase/Classes/Object/ObjectManager.php b/typo3/sysext/extbase/Classes/Object/ObjectManager.php
index 0f8baafbd046..2849fe28f2c6 100644
--- a/typo3/sysext/extbase/Classes/Object/ObjectManager.php
+++ b/typo3/sysext/extbase/Classes/Object/ObjectManager.php
@@ -62,13 +62,9 @@ class ObjectManager implements ObjectManagerInterface
      * @return array Names of the properties to be serialized
      * @internal only to be used within Extbase, not part of TYPO3 Core API.
      */
-    public function __sleep()
+    public function __sleep(): array
     {
-        // Use get_objects_vars() instead of
-        // a much more expensive Reflection:
-        $properties = get_object_vars($this);
-        unset($properties['objectContainer']);
-        return array_keys($properties);
+        return [];
     }
 
     /**
-- 
GitLab