N°8286 - fix call to CompleteSessionData in case of no proper session content

This commit is contained in:
odain
2025-06-19 11:29:48 +02:00
parent 83eb2b81e3
commit 5573a222c8
2 changed files with 10 additions and 1 deletions

View File

@@ -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=[];
}
}

View File

@@ -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");
}
}