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