Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

AuthenticationUtils::getLastUsername(): Return value must be of type string, null returned #53503

Copy link
Copy link
Closed
@r3dge

Description

@r3dge
Issue body actions

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();

    if ($request->attributes->has(SecurityRequestAttributes::LAST_USERNAME)) {
        return $request->attributes->get(SecurityRequestAttributes::LAST_USERNAME, '');
    }

    return $request->hasSession() ? $request->getSession()->get(SecurityRequestAttributes::LAST_USERNAME, '') : '';
}

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.