Skip to content

[Security] FirewallAwareTrait throws Critical Error instead of throwing Exception #43145

Closed
@fkropfhamer

Description

@fkropfhamer

Symfony version(s) affected: 5.3.7

Description

The Symfony/Bundle/SecurityBundle/Security/FirewallAwareTrait throws Critical Error instead of throwing the right Exception with helpfull Message.
The Error thrown is "Call to undefined function Symfony\Bundle\SecurityBundle\LoginLink\LoginLinkHandler()".
The right Error message, I assume, would be "Cannot determine the correct Symfony\Bundle\SecurityBundle\LoginLink\LoginLinkHandler to use: there is no active Request and so, the firewall cannot be determined. Try using a specific Symfony\Bundle\SecurityBundle\LoginLink\Logi
nLinkHandler service."

How to reproduce

  1. Create new Symfony project with php 7.4 symfony new my_project_name --full
  2. Configure login link like described here
  3. Create new Command, inject LoginLinkHandlerInterface and try to call $this->loginLinkHandler->createLoginLink($user);
  4. Execute Command and take a look at the Error message.

Possible Solution

Change Symfony/Bundle/SecurityBundle/Security/FirewallAwareTrait line to
throw new \LogicException('Cannot determine the correct '.$serviceIdentifier.' to use: there is no active Request and so, the firewall cannot be determined. Try using a specific '.$serviceIdentifier.' service.');

Additional context

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