From 2df5804d3d034db26cef5a9ca8c584be3222c074 Mon Sep 17 00:00:00 2001
From: Marcus Eibrink-Lunzenauer <lunzenauer@elan-ev.de>
Date: Fri, 14 Jun 2024 08:59:22 +0000
Subject: [PATCH] Add __(un)serialize to `StudipArrayObject` to remove
 Warnings.

Closes #4135

Merge request studip/studip!3098
---
 lib/classes/StudipArrayObject.class.php | 32 +++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/lib/classes/StudipArrayObject.class.php b/lib/classes/StudipArrayObject.class.php
index 531da670d8d..da7e66eb677 100644
--- a/lib/classes/StudipArrayObject.class.php
+++ b/lib/classes/StudipArrayObject.class.php
@@ -134,6 +134,38 @@ class StudipArrayObject implements IteratorAggregate, ArrayAccess, Serializable,
         return $this->$key;
     }
 
+    /**
+     * Called when serializing an ArrayObject
+     */
+    public function __serialize(): array
+    {
+        return get_object_vars($this);
+    }
+
+    /**
+     * Called when unserializing an ArrayObject
+     */
+    public function __unserialize(array $data): void
+    {
+        foreach ($data as $k => $v) {
+            switch ($k) {
+                case 'flag':
+                    $this->setFlags($v);
+                    break;
+                case 'storage':
+                    $this->exchangeArray($v);
+                    break;
+                case 'iteratorClass':
+                    $this->setIteratorClass($v);
+                    break;
+                case 'protectedProperties':
+                    break;
+                default:
+                    $this->__set($k, $v);
+            }
+        }
+    }
+
     /**
      * Appends the value
      *
-- 
GitLab