[Security] fixed a fatal error when upgrading from 4.2

This commit is contained in:
Fabien Potencier 2019-05-21 21:22:42 +02:00 committed by Nicolas Grekas
parent 7f43878d9c
commit cd63446f9b
1 changed files with 9 additions and 1 deletions

View File

@ -199,7 +199,15 @@ abstract class AbstractToken implements TokenInterface
*/
public function __unserialize(array $data): void
{
[$this->user, $this->authenticated, $this->roles, $this->attributes, $this->roleNames] = $data;
[$this->user, $this->authenticated, $this->roles, $this->attributes] = $data;
// migration path to 4.3+
if (null === $this->roleNames = $data[4] ?? null) {
$this->roleNames = [];
foreach ($this->roles as $role) {
$this->roleNames[] = (string) $role;
}
}
}
/**