问题描述
我们在不同的子域上有 2 个应用程序,共享同一个会话。一个应用程序是最新的 Symfony 3.4,另一个是最新的 Symfony 4.4。到目前为止,没有问题。
我们将环境从 PHP 7.3.5 升级或测试到 PHP 7.4.11,在通过 Symfony 4.4 应用程序后,经过身份验证的会话丢失了。
Symfony 3.4 在反序列化时静默失败并使用匿名令牌填充 tokenStorage。
记录的 Symfony 3.4 异常的转储:
{
"message": "Failed to unserialize the security token from the session.","context": {
"key": "_security_secured_area","received": "O:67:\"Symfony\\Component\\Security\\Guard\\Token\\PostAuthenticationGuardToken\":....}","exception": {
"class": "UnexpectedValueException","message": "Erroneous data format for unserializing 'Symfony\\Component\\Security\\Guard\\Token\\PostAuthenticationGuardToken'","code": 57873340,"file": "/var/www/.../vendor/symfony/symfony/src/Symfony/Component/Security/Http/Firewall/ContextListener.PHP:250"
}
},"level": 300,"level_name": "WARNING","channel": "security",}
我们以前从未见过这种异常,也不知道如何开始调试。
有什么建议吗?
解决方法
我最终将 Symfony 3.4 应用程序升级到最新的 Symfony 4。