Description
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
- Create new Symfony project with php 7.4
symfony new my_project_name --full
- Configure login link like described here
- Create new Command, inject LoginLinkHandlerInterface and try to call
$this->loginLinkHandler->createLoginLink($user);
- 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