Skip to content

fix: remove deprecated eraseCredentials() — breaks logout on Symfony 8#111

Draft
smbpunt wants to merge 1 commit intoecphp:masterfrom
smbpunt:fix/remove-deprecated-eraseCredentials
Draft

fix: remove deprecated eraseCredentials() — breaks logout on Symfony 8#111
smbpunt wants to merge 1 commit intoecphp:masterfrom
smbpunt:fix/remove-deprecated-eraseCredentials

Conversation

@smbpunt
Copy link
Copy Markdown

@smbpunt smbpunt commented Mar 26, 2026

Summary

  • Remove empty eraseCredentials() method from CasUser
  • Remove $security->getToken()?->eraseCredentials() call from Logout controller
  • Remove now-unused Security dependency from Logout controller

Context

eraseCredentials() was deprecated in Symfony 7.3 and removed in 8.0. Since cas-bundle now supports Symfony 8 ("symfony/framework-bundle": "^7 || ^8"), the call in the Logout controller causes a fatal error, breaking logout entirely.

Ref: https://symfony.com/blog/new-in-symfony-7-3-security-improvements#deprecate-erasecredentials-method

`eraseCredentials()` was deprecated in Symfony 7.3 and removed in 8.0.

- Remove empty `eraseCredentials()` from `CasUser`
- Remove `$security->getToken()?->eraseCredentials()` call from `Logout` controller
- Remove unused `Security` dependency from `Logout` controller

Ref: https://symfony.com/blog/new-in-symfony-7-3-security-improvements#deprecate-erasecredentials-method
@smbpunt smbpunt marked this pull request as draft March 26, 2026 12:48
@smbpunt
Copy link
Copy Markdown
Author

smbpunt commented Mar 26, 2026

Heads up — compatibility concern with this PR as-is.

Removing eraseCredentials() from the Logout controller fixes the SF8 fatal error, but removing it from CasUser breaks Symfony 7.x: UserInterface still declares eraseCredentials() in all 7.x versions (deprecated in 7.3, only removed from the interface in 8.0). Since composer.json declares "^7 || ^8", this would cause a fatal error for all SF7 users.

How would you like to handle this @drupol ? Should I adjust the PR, or do you prefer a different approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant