Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Security] Fix serialized object representation in tests #58423

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2024

Conversation

alexandre-daubois
Copy link
Member

@alexandre-daubois alexandre-daubois commented Sep 30, 2024

Q A
Branch? 5.4
Bug fix? no
New feature? no
Deprecations? no
Issues -
License MIT

LegacyRoleTest triggers the following error:

Legacy deprecation triggered by Symfony\Component\Security\Core\Tests\Role\LegacyRoleTest::testPayloadFromV4CanBeUnserialized:
Creation of dynamic property Symfony\Component\Security\Core\Role\Role::$Symfony\Component\Security\Core\Role\Role is deprecated

{
public function testPayloadFromV4CanBeUnserialized()
{
$serialized = 'C:74:"Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken":236:{a:3:{i:0;N;i:1;s:4:"main";i:2;a:5:{i:0;s:2:"sf";i:1;b:1;i:2;a:1:{i:0;O:41:"Symfony\Component\Security\Core\Role\Role":1:{s:47:"Symfony\Component\Security\Core\Role\Role'."\0".'role'."\0".'";s:9:"ROLE_USER";}}i:3;a:0:{}i:4;a:1:{i:0;s:9:"ROLE_USER";}}}}';
Copy link
Member

@nicolas-grekas nicolas-grekas Oct 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather keep the files but fix the serialized payload, which is incorrect (branch 5.4 I guess):

-"Symfony\Component\Security\Core\Role\Role'."\0".'role'."\0".'"
+"'."\0".'Symfony\Component\Security\Core\Role\Role'."\0".'role"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, the deprecation notice is gone. Thanks!

@alexandre-daubois alexandre-daubois changed the base branch from 7.2 to 5.4 October 1, 2024 11:25
@alexandre-daubois alexandre-daubois changed the title [Security] Remove legacy internal classes [Security] Fix serialized object representation in tests Oct 1, 2024
@nicolas-grekas nicolas-grekas modified the milestones: 7.2, 5.4 Oct 1, 2024
@nicolas-grekas
Copy link
Member

Thank you @alexandre-daubois.

@nicolas-grekas nicolas-grekas merged commit 18ad416 into symfony:5.4 Oct 1, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants