Closed
Description
Symfony version(s) affected: ^4.4.22, ^5.2.7 and ^5.3.0
Description
Since the commit 2876c we can no longer use URL Env Var Processor functionality to fill router.request_context.base_url
in the configuration, because the method Symfony\Component\Routing\RequestContext::fromUri
does not accept null.
How to reproduce
To reproduce this we can set an environment variable: ROUTER_REQUEST_CONTEXT_URL with a url like: https://symfony.com
with nothing as a path, then set some parameters like:
parameters:
router.request_context.host: '%env(string:key:host:url:ROUTER_REQUEST_CONTEXT_URL)%'
router.request_context.scheme: '%env(string:key:scheme:url:ROUTER_REQUEST_CONTEXT_URL)%'
router.request_context.base_url: '%env(string:key:path:url:ROUTER_REQUEST_CONTEXT_URL)%'
Possible Solution
Two possible solutions:
- Rollback the commit
- Make Symfony\Component\Routing\RequestContext::fromUr accepts null.
Error as shown in console
CRITICAL [php] Uncaught Error: Symfony\Component\Routing\RequestContext::fromUri(): Argument #1 ($uri) must be of type
string, null given, called in /home/me/myProject/var/cache/dev/ContainerXfMbE5x/App_KernelDevDebugContainer.php on line
2098