Description
Symfony version(s) affected
4.4.44
Description
Method generateLogoutUrl of LogoutUrlGenerator throws "Call to a member function getBaseUrl() on null" error.
It can be reproduced by generating error after authenticating as a user. Error is not present after logging out.
Similar issue is described on #27174
On Symfony 6.1 this problem does not occur on same setup.
Tested using PHP 8.1 (Ubuntu supplied) with built in server.
How to reproduce
Install symfony/website-skeleton:"^4.4" with dev environment
Add db based authentication
Login
Generate error
Possible Solution
Checking for null request in LogoutUrlGenerator - there was previously supplied PR which fixes this problem:
#27175
It was rejected because problem was not reproduced (or should not exist).
But I think that in any case if called function can return null then it should be checked against null before calling its methods.
Additional Context
Call to a member function getBaseUrl() on null
Exception Stack Trace
Error
in vendor/symfony/security-http/Logout/LogoutUrlGenerator.php (line 110)
in vendor/symfony/security-http/Logout/LogoutUrlGenerator.php -> generateLogoutUrl (line 64)
in vendor/symfony/security-bundle/DataCollector/SecurityDataCollector.php -> getLogoutPath (line 136)
in vendor/symfony/http-kernel/Profiler/Profiler.php -> collect (line 178)
in vendor/symfony/http-kernel/EventListener/ProfilerListener.php -> collect (line 100)
in vendor/symfony/event-dispatcher/Debug/WrappedListener.php -> onKernelResponse (line 126)
in vendor/symfony/event-dispatcher/EventDispatcher.php -> __invoke (line 264)
in vendor/symfony/event-dispatcher/EventDispatcher.php -> doDispatch (line 239)
in vendor/symfony/event-dispatcher/EventDispatcher.php -> callListeners (line 73)
in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php -> dispatch (line 168)
in vendor/symfony/http-kernel/HttpKernel.php -> dispatch (line 192)
in vendor/symfony/http-kernel/HttpKernel.php -> filterResponse (line 245)
in vendor/symfony/http-kernel/HttpKernel.php -> handleThrowable (line 115)
in vendor/symfony/http-kernel/EventListener/DebugHandlersListener.php -> terminateWithException (line 129)
in vendor/symfony/error-handler/ErrorHandler.php :: Symfony\Component\HttpKernel\EventListener{closure} (line 601)
ErrorHandler->handleException()