From 6b1217c2cfcf9fee9c1bbf1b9cdd3dcb02101da3 Mon Sep 17 00:00:00 2001
From: Thibault Dockx <thibault.dockx@fusiondirectory.org>
Date: Mon, 13 Jan 2025 21:17:26 +0000
Subject: [PATCH] :sparkles: (CORE) - progression of un-seralization 3

Login success and ldap edit success
---
 html/index.php            |  2 --
 include/class_config.inc  | 27 +++++++++++++++++++++++++++
 include/class_session.inc | 10 +---------
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/html/index.php b/html/index.php
index c12614ca3..5659b9f38 100755
--- a/html/index.php
+++ b/html/index.php
@@ -100,8 +100,6 @@ if (!is_readable(CONFIG_DIR.'/'.CONFIG_FILE)) {
 $config = new config(CONFIG_DIR.'/'.CONFIG_FILE, $BASE_DIR);
 
 session::set('config', $config);
-print_r($_SESSION);
-
 session::set('DEBUGLEVEL', $config->get_cfg_value('DEBUGLEVEL'));
 logging::debug(DEBUG_CONFIG, __LINE__, __FUNCTION__, __FILE__, $config->data, 'config');
 /* Configuration was reloaded, so plist needs to be as well */
diff --git a/include/class_config.inc b/include/class_config.inc
index 46e8954ab..e05b5e95c 100755
--- a/include/class_config.inc
+++ b/include/class_config.inc
@@ -83,6 +83,33 @@ class config
     }
   }
 
+  public function __serialize (): array
+  {
+    return [
+      'config_found' => $this->config_found,
+      'tags' => $this->tags,
+      'level' => $this->level,
+      'currentLocation' => $this->currentLocation,
+      'current' => $this->current,
+      'referrals' => $this->referrals,
+      'data' => $this->data,
+    ];
+  }
+
+  public function __unserialize(array $data): void
+  {
+    $this->config_found = $data['config_found'];
+    $this->tags = $data['tags'];
+    $this->level = $data['level'];
+    $this->currentLocation = $data['currentLocation'];
+    $this->current = $data['current'];
+    $this->referrals = $data['referrals'];
+    $this->data = $data['data'];
+
+    // Recreate the XML parser
+    $this->parser = xml_parser_create();
+  }
+
   /*!
    * \brief Check and reload the configuration
    *
diff --git a/include/class_session.inc b/include/class_session.inc
index 286d14cce..5db5e9aab 100755
--- a/include/class_session.inc
+++ b/include/class_session.inc
@@ -56,9 +56,6 @@ class session
    */
   public static function set ($name, $value)
   {
-    if ($name === 'config') {
-      $value = pack('C',$value);
-    }
     $_SESSION[$name] = $value;
   }
 
@@ -77,12 +74,7 @@ class session
    */
   public static function get ($name)
   {
-    if ($name === 'config') {
-      if (isset($_SESSION['config'])) {
-        return unpack('C', $_SESSION[$name]);
-      }
-    }
-    else if (isset($_SESSION[$name])) {
+   if (isset($_SESSION[$name])) {
       return $_SESSION[$name];
     } else {
       return NULL;
-- 
GitLab