8000 bug #31566 [Security] fixed a fatal error when upgrading from 4.2 (fa… · symfony/symfony@31ba038 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31ba038

Browse files
bug #31566 [Security] fixed a fatal error when upgrading from 4.2 (fabpot)
This PR was merged into the 4.3 branch. Discussion ---------- [Security] fixed a fatal error when upgrading from 4.2 | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | n/a | License | MIT | Doc PR | n/a This is needed when upgrading a project from 4.2 to 4.3 to avoid a fatal PHP error when unserializing a token serialized on 4.2. Commits ------- cd63446 [Security] fixed a fatal error when upgrading from 4.2
2 parents 7f43878 + cd63446 commit 31ba038

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Symfony/Component/Security/Core/Authentication/Token/AbstractToken.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,15 @@ public function serialize()
199199
*/
200200
public function __unserialize(array $data): void
201201
{
202-
[$this->user, $this->authenticated, $this->roles, $this->attributes, $this->roleNames] = $data;
202+
[$this->user, $this->authenticated, $this->roles, $this->attributes] = $data;
203+
204+
// migration path to 4.3+
205+
if (null === $this->roleNames = $data[4] ?? null) {
206+
$this->roleNames = [];
207+
foreach ($this->roles as $role) {
208+
$this->roleNames[] = (string) $role;
209+
}
210+
}
203211
}
204212

205213
/**

0 commit comments

Comments
 (0)
0