Problem/Motivation

When adding a redirect whose source includes a query string, the source widget shows:

> The base source path %source is already being redirected. Do you want to edit the existing redirect?

…whenever *any* other redirect already exists on the same base path — even when that existing redirect has a **different** query string.

This is a false positive on sites that legitimately use many redirects that share a base path but differ by query string (for example legacy `index.php?id=1` / `index.php?id=2`, or `WorkArea/linkit.aspx?ItemID=…` URLs). The warning even links the editor to an unrelated redirect (the first match on the base path).

The redirect still saves and resolves correctly — uniqueness (`UniqueHash`) and lookup (`RedirectRepository::findMatchingRedirect()`) both key off the full path + query + language hash. Only the widget's status-box warning is wrong: it calls `RedirectRepository::findBySourcePath()`, which matches the path only and ignores the query string.

This is the cosmetic remainder of #2803105 (which fixed the hard validation for query-varying redirects); the status-box warning still uses path-only matching.

Steps to reproduce

1. Create a redirect from `test?a=1` to any destination.
2. Add a new redirect from `test?a=2`.
3. The widget warns that `test?a=2` is already being redirected and links to the `test?a=1` redirect, even though they are distinct, valid redirects.

Proposed resolution

In `RedirectSourceWidget::formElement()`, parse the query string from the entered source and only show the warning when an existing redirect on that path also matches the query string (a genuine duplicate): iterate the `findBySourcePath()` results and compare each redirect's `getSource()['query']` to the parsed query.

Remaining tasks

- Review.
- Test: extend `RedirectJavascriptTest` to assert no warning is shown for a query-only difference.

Issue fork redirect-3601798

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

ethant created an issue. See original summary.

ethant’s picture

Status: Active » Closed (works as designed)

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.