Skip to content

[DependencyInjection] [Routing] BC break: router.request_context.base_url with key:path:url: doesn't work anymore in configuration since 5.2.7 #43258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amouhzi opened this issue Sep 30, 2021 · 0 comments

Comments

@amouhzi
Copy link
Contributor

amouhzi commented Sep 30, 2021

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
@amouhzi amouhzi added the Bug label Sep 30, 2021
@amouhzi amouhzi changed the title [DependencyInjection] [Routing] BC break key:path:url: doesn't work anymore in configuration since 5.2.7 [DependencyInjection] [Routing] BC break router.request_context.base_url with key:path:url: doesn't work anymore in configuration since 5.2.7 Sep 30, 2021
@amouhzi amouhzi changed the title [DependencyInjection] [Routing] BC break router.request_context.base_url with key:path:url: doesn't work anymore in configuration since 5.2.7 [DependencyInjection] [Routing] BC break: router.request_context.base_url with key:path:url: doesn't work anymore in configuration since 5.2.7 Sep 30, 2021
@fabpot fabpot closed this as completed Oct 18, 2021
fabpot added a commit that referenced this issue Oct 18, 2021
…-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[DependencyInjection] fix "url" env var processor

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | #43258
| License       | MIT
| Doc PR        | -

Commits
-------

5a75f48 [DependencyInjection] fix "url" env var processor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants