Bug #90744
Updated by Matthias Krams over 4 years ago
The RedisSessionBackend (typo3/sysext/core/Classes/Session/Backend/RedisSessionBackend.php) throws an error if the data stored in Redis cannot be decoded. There is a bug in the get method. An array is expected as return value. But if the function "json_decode" returns null, TYPO3 throws the error: "Core: Exception handler (WEB): Uncaught TYPO3 Exception: Return value of TYPO3\CMS\Core\Session\Backend\RedisSessionBackend::get() must be of the type array, null returned".
*Current*
<pre>
/**
* Read session data
*
* @param string $sessionId
* @return array Returns the session data
* @throws SessionNotFoundException
*/
public function get(string $sessionId): array
{
$this->initializeConnection();
$key = $this->getSessionKeyName($sessionId);
$rawData = $this->redis->get($key);
if ($rawData !== false) {
return json_decode(
$rawData,
true
);
}
throw new SessionNotFoundException('Session could not be fetched from redis', 1481885583);
}
</pre>
*Fixed*
<pre>
/**
* Read session data
*
* @param string $sessionId
* @return array Returns the session data
* @throws SessionNotFoundException
*/
public function get(string $sessionId): array
{
$this->initializeConnection();
$key = $this->getSessionKeyName($sessionId);
$rawData = $this->redis->get($key);
if ($rawData !== false) {
$sessionData = json_decode(
$rawData,
true
);
if(!is_null($sessionData)) {
return $sessionData;
}
}
throw new SessionNotFoundException('Session could not be fetched from redis', 1481885583);
}
</pre>