-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
AuthenticationUtils::getLastUsername(): Return value must be of type string, null returned #53503
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
Comments
Looks like you need to investigate why Can you create a small example application that allows to reproduce your issue? |
This anomaly occurs randomly. I find it regularly in the production logs but I don't know how to reproduce it. |
I don't know why sometimes the return of the getlastUsername is null (return $request->hasSession() ? $request->getSession()->get(SecurityRequestAttributes::LAST_USERNAME, '') : '';) I am trying to implement a workaround in my login controller like that :
|
…turning null (alexandre-daubois) This PR was merged into the 5.4 branch. Discussion ---------- [Security] Fix `AuthenticationUtils::getLastUsername()` returning null | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #53503 | License | MIT This can happen when the attribute is actually set with `null`. Covered the class while at it. Commits ------- 2e52b06 [Security] Fix `AuthenticationUtils::getLastUsername()` returning null
Symfony version(s) affected
6.4.1
Description
In production environment i get regularly this exception in logs :
Uncaught PHP Exception TypeError: "Symfony\Component\Security\Http\Authentication\AuthenticationUtils::getLastUsername(): Return value must be of type string, null returned" at AuthenticationUtils.php
How to reproduce
I don't know exactly what trigger this exception
Possible Solution
Changing the return type of the method :
public function getLastUsername(): ?string
{
$request = $this->getRequest();
Additional Context
No response
The text was updated successfully, but these errors were encountered: