Skip to content

Better handling of router-level redirections #28806

Closed
@stof

Description

@stof

Description
Currently, router-level redirections require to use a special controller performing the redirection. But this has several drawbacks:

  • the component cannot provide a RedirectableUrlMatcher, as it cannot have such controller (it does not know about the concept of controller), forcing to keep this child class in FrameworkBundle
  • the redirection is not performed at the time the router runs. Instead, a route is almost matched, and things continue to run in the normal request handling (which means running the security layer for instance, and other request listeners) even though the route was not actually matched. This was reported as a bug in the past (I could not find it again right now). This is especially painful as _route is returned as the route which was not actually matched (but redirected to, to match), which means that the contract for this attribute is not actually that it is the name of the matched route.

A better solution would be to specify a dedicated return format for the matcher, which would tell the RouterListener that it must redirect (which it can do by setting a response, which will stop the request handling early).

We might still need to return the existing (lying) properties alongside the redirection marker to preserve BC for places calling the UrlMatcher directly outside the RouterListener.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions