Skip to content

Commit 52dad31

Browse files
[Security] Improve BC-layer to deprecate eraseCredentials methods
1 parent 4b84f87 commit 52dad31

File tree

5 files changed

+11
-110
lines changed

5 files changed

+11
-110
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ CHANGELOG
44
7.3
55
---
66

7-
* Deprecate `LdapUser::eraseCredentials()`, use `LdapUser::setPassword(null)` instead
8-
* Add `EraseLdapUserCredentialsListener`
7+
* Deprecate `LdapUser::eraseCredentials()` in favor of `__serialize()`
98

109
7.2
1110
---

Security/EraseLdapUserCredentialsListener.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

Security/LdapUser.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,15 @@ public function getUserIdentifier(): string
6060
return $this->identifier;
6161
}
6262

63+
/**
64+
* @deprecated since Symfony 7.3
65+
*/
66+
#[\Deprecated(since: 'symfony/ldap 7.3')]
6367
public function eraseCredentials(): void
6468
{
65-
trigger_deprecation('symfony/security-core', '7.3', sprintf('The "%s()" method is deprecated and will be removed in 8.0, call "setPassword(null)" instead.', __METHOD__));
69+
if (\PHP_VERSION_ID < 80400) {
70+
@trigger_error(\sprintf('Method %s::eraseCredentials() is deprecated since symfony/ldap 7.3', self::class), \E_USER_DEPRECATED);
71+
}
6672

6773
$this->password = null;
6874
}
@@ -100,11 +106,9 @@ public function isEqualTo(UserInterface $user): bool
100106

101107
public function __serialize(): array
102108
{
103-
return [$this->entry, $this->identifier, null, $this->roles, $this->extraFields];
104-
}
109+
$data = (array) $this;
110+
unset($data[\sprintf("\0%s\0password", self::class)]);
105111

106-
public function __unserialize(array $data): void
107-
{
108-
[$this->entry, $this->identifier, $this->password, $this->roles, $this->extraFields] = $data;
112+
return $data;
109113
}
110114
}

Tests/Security/EraseLdapUserCredentialsListenerTest.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"require": {
1919
"php": ">=8.2",
2020
"ext-ldap": "*",
21-
"symfony/deprecation-contracts": "^2.5|^3",
2221
"symfony/options-resolver": "^6.4|^7.0"
2322
},
2423
"require-dev": {

0 commit comments

Comments
 (0)