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
Issue fork sites_redirect-3605736
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
Comment #2
hydra commentedComment #5
hydra commented