Problem/Motivation

With "Automatically create redirects" on, changing a URL alias fails if a disabled redirect in the alias's language starts from the old alias. Saving throws an EntityStorageException for a duplicate hash, and the alias can't be changed until someone deletes the disabled redirect.

RedirectEntityHooks::pathAliasUpdate() calls findMatchingRedirect() before it creates the redirect from the old alias. That method only finds enabled redirects, so it misses the disabled one, and the new redirect hits the unique key on hash.

Steps to reproduce

  1. Turn on "Automatically create redirects".
  2. Give a page the alias /about-us.
  3. Add a redirect from about-us to another page, in the page's language, and disable it. The form warns that the path already exists; submit it again.
  4. Change the page's alias to /about.

Saving fails with "SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry". Reproduced on 8.x-1.13.

Proposed resolution

Look up the redirect from the old alias by its hash, disabled ones included. If there is one, point it at the alias's path and enable it, instead of creating another.

Remaining tasks

  • Merge request with a kernel test.

AI Disclosure

Generated with the help of an LLM. I found this while working on code that moves URL aliases. Claude Code traced it through Redirect's code, reproduced it on a local site and drafted this issue; I reviewed it.

Comments

dave reid created an issue.