From 65b6c0f4ea9605f276b518f9d69b0db60ecc40db Mon Sep 17 00:00:00 2001 From: Eric Espie Date: Wed, 23 Nov 2022 11:04:58 +0100 Subject: [PATCH] Fix CI --- core/userrights.class.inc.php | 1 - sources/application/Helper/Session.php | 16 +++------------- test/application/Session/SessionTest.php | 8 ++++++++ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/core/userrights.class.inc.php b/core/userrights.class.inc.php index 2edd33a04..9b9a3cc0c 100644 --- a/core/userrights.class.inc.php +++ b/core/userrights.class.inc.php @@ -1838,7 +1838,6 @@ class UserRights self::$m_aAdmins = array(); self::$m_aPortalUsers = array(); } - Session::FlushSession(); self::_ResetSessionCache(); if (self::$m_oAddOn) { diff --git a/sources/application/Helper/Session.php b/sources/application/Helper/Session.php index 547f933c4..0facb2669 100644 --- a/sources/application/Helper/Session.php +++ b/sources/application/Helper/Session.php @@ -49,19 +49,6 @@ class Session } } - public static function FlushSession() - { - if (self::IsModeCLI()) { - return; - } - - if (!is_null(self::$iSessionId)) { - self::$bIsInitialized = false; - self::$bSessionStarted = false; - self::Start(); - } - } - public static function RegenerateId($bDeleteOldSession = false) { if (self::IsModeCLI()) { @@ -69,6 +56,9 @@ class Session } session_regenerate_id($bDeleteOldSession); + if (self::$bSessionStarted) { + self::WriteClose(); + } self::$bSessionStarted = session_start(); self::$iSessionId = session_id(); } diff --git a/test/application/Session/SessionTest.php b/test/application/Session/SessionTest.php index ee1ce14ad..fbc598da6 100644 --- a/test/application/Session/SessionTest.php +++ b/test/application/Session/SessionTest.php @@ -133,4 +133,12 @@ class SessionTest extends ItopTestCase $this->assertFalse(Session::IsSet(['test1', 'test2', 'test3'])); } + public function testRegenerateId() + { + Session::Start(); + $iPrevSessionId = Session::$iSessionId; + Session::RegenerateId(); + //$this->assertFalse(Session::IsSet('test')); + $this->assertNotEquals($iPrevSessionId, Session::$iSessionId); + } }