From 5573a222c82d3497b82c73ca1d2a899603d04848 Mon Sep 17 00:00:00 2001 From: odain Date: Thu, 19 Jun 2025 11:29:48 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B08286=20-=20fix=20call=20to=20CompleteSes?= =?UTF-8?q?sionData=20in=20case=20of=20no=20proper=20session=20content?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/SessionTracker/SessionHandler.php | 2 +- .../sources/SessionTracker/SessionHandlerTest.php | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/sources/SessionTracker/SessionHandler.php b/sources/SessionTracker/SessionHandler.php index 4548eb82e..8096e80da 100644 --- a/sources/SessionTracker/SessionHandler.php +++ b/sources/SessionTracker/SessionHandler.php @@ -147,7 +147,7 @@ class SessionHandler extends \SessionHandler $iCreationTime = $aJson['creation_time']; } } else { - IssueLog::Debug(__METHOD__ . ': not a json due (session file corruption?)', null, [ 'sPreviousFileVersionContent' => $sPreviousFileVersionContent ]); + $aJson=[]; } } diff --git a/tests/php-unit-tests/unitary-tests/sources/SessionTracker/SessionHandlerTest.php b/tests/php-unit-tests/unitary-tests/sources/SessionTracker/SessionHandlerTest.php index 5e51cb2a7..44a958c45 100644 --- a/tests/php-unit-tests/unitary-tests/sources/SessionTracker/SessionHandlerTest.php +++ b/tests/php-unit-tests/unitary-tests/sources/SessionTracker/SessionHandlerTest.php @@ -316,4 +316,13 @@ class SessionHandlerTest extends ItopDataTestCase $this->assertEquals('gabuzomeu', $aJson['shadok'] ?? '', "Should report the current login mode in [shadok]: $sFirstContent"); } + + public function testGenerateSessionContentWithPreviousNonArrayContentAndWithAdditionalDataProvidedBySessionHandlerExtension() + { + \utils::GetConfig()->Set('sessions_tracking.session_handler_extension', 'Combodo\iTop\Test\UnitTest\SessionTracker\BasicSessionHandlerExtension'); + $this->CreateUserAndLogIn(); + $oSessionHandler = new SessionHandler(); + $sContent = $this->GenerateSessionContent($oSessionHandler, json_encode(null)); + $this->assertNotNull($sContent, "Call to CompleteSessionData should NOT fail due to Argument #1 (\$aJson) must be of type array, null given"); + } } \ No newline at end of file