Problem/Motivation

When a redirect chain crosses sites, the chain resolves one hop short.
`SitesRedirectRepository::findMatchingRedirect()` follows chained redirects
via the inherited `RedirectRepository::findByRedirect()`, which re-resolves the
next hop using the *current* site instead of the redirect's *target* site
(`site_id` redirect option). So a redirect on site A that points to a path
served by a redirect on site B stops at the first hop.

Steps to reproduce

1. Run two sites (e.g. `foo`, `bar`) with the Sites module.
2. On `bar`, create redirect B: `/page-b` → `/node/9`.
3. On `foo`, create redirect A: `/page-a` → `/page-b`, target site `bar`.
4. Visit `/page-a` on `foo`. It resolves to `/page-b` instead of `/node/9`.

Proposed resolution

Override `findByRedirect()` in `SitesRedirectRepository` to pass the redirect's
target `site_id` into `findMatchingRedirect()`. Inject `request_stack` and
`redirect.prefix_list` into the repository (also clears the redirect
1.11/1.12 constructor deprecation).

Remaining tasks

  • Override `findByRedirect()` with target-site awareness
  • Inject `request_stack` + `redirect.prefix_list`
  • Kernel test for a cross-site chain
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

hydra created an issue. See original summary.

hydra’s picture

Version: » 1.x-dev
Issue summary: View changes

  • hydra committed eb8c1370 on 1.x
    fix: #3605736 Chained redirects across sites lose their target site...
hydra’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.