Skip to content

Commit d3e8169

Browse files
committed
bug #1743 do not implement __serialize() for users without passwords (xabbuh)
This PR was squashed before being merged into the 1.x branch. Discussion ---------- do not implement `__serialize()` for users without passwords Commits ------- d67cf83 fix the Maker test environment fafd951 run tests with Symfony 7.3 4ba90e1 do not implement __serialize() for users without passwords
2 parents c86da84 + d67cf83 commit d3e8169

File tree

5 files changed

+4
-26
lines changed

5 files changed

+4
-26
lines changed

.github/workflows/ci-linux.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- '8.3'
4646
symfony-version:
4747
- '6.4.*'
48-
- '7.2.*'
48+
- '7.3.*'
4949
dependency-versions: ['highest']
5050
include:
5151
# testing lowest PHP+dependencies with lowest Symfony

src/Security/UserClassBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function addUserInterfaceImplementation(ClassSourceManipulator $manipulat
3838

3939
$this->addPasswordImplementation($manipulator, $userClassConfig);
4040

41-
if (class_exists(IsGrantedContext::class)) {
41+
if (class_exists(IsGrantedContext::class) && $userClassConfig->hasPassword()) {
4242
$this->addSerialize($manipulator);
4343
}
4444

src/Test/MakerTestEnvironment.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ private function buildFlexSkeleton(): void
246246
$flexProjectDir = \sprintf('flex_project%s', $targetVersion);
247247

248248
MakerTestProcess::create(
249-
\sprintf('composer create-project symfony/skeleton%s %s --prefer-dist --no-progress', $versionString, $flexProjectDir),
249+
\sprintf('composer create-project symfony/skeleton%s %s --prefer-dist --no-progress --keep-vcs', $versionString, $flexProjectDir),
250250
$this->cachePath
251251
)->run();
252252

@@ -260,7 +260,7 @@ private function buildFlexSkeleton(): void
260260
}
261261

262262
// fetch a few packages needed for testing
263-
MakerTestProcess::create('composer require phpunit browser-kit symfony/css-selector --prefer-dist --no-progress --no-suggest', $this->flexPath)
263+
MakerTestProcess::create('composer require phpunit:1.1.* browser-kit symfony/css-selector --prefer-dist --no-progress --no-suggest', $this->flexPath)
264264
->run();
265265

266266
if ('\\' !== \DIRECTORY_SEPARATOR) {

tests/Security/fixtures/expected/UserEntityWithoutPassword.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,6 @@ public function setRoles(array $roles): static
6767
return $this;
6868
}
6969

70-
/**
71-
* Ensure the session doesn't contain actual password hashes by CRC32C-hashing them, as supported since Symfony 7.3.
72-
*/
73-
public function __serialize(): array
74-
{
75-
$data = (array) $this;
76-
$data["\0" . self::class . "\0password"] = hash('crc32c', $this->password);
77-
78-
return $data;
79-
}
80-
8170
#[\Deprecated]
8271
public function eraseCredentials(): void
8372
{

tests/Security/fixtures/expected/UserModelWithoutPassword.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,6 @@ public function setRoles(array $roles): static
5252
return $this;
5353
}
5454

55-
/**
56-
* Ensure the session doesn't contain actual password hashes by CRC32C-hashing them, as supported since Symfony 7.3.
57-
*/
58-
public function __serialize(): array
59-
{
60-
$data = (array) $this;
61-
$data["\0" . self::class . "\0password"] = hash('crc32c', $this->password);
62-
63-
return $data;
64-
}
65-
6655
#[\Deprecated]
6756
public function eraseCredentials(): void
6857
{

0 commit comments

Comments
 (0)