Problem/Motivation

Trashing a redirect sets its hash to deleted-<uuid>, so a new redirect can use the same source. Inside a workspace that change is only in the workspace revision. The base table keeps the old hash until the workspace is published, and the hash has a unique key there.

A new redirect from the same source in that workspace passes validation, because Trash hides the trashed redirect from the RedirectUniqueHash check. Saving it then fails:

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '...' for key 'redirect.hash'

This needs redirects to be workspace-supported (#3313540: Convert the Redirect entity type to revisionable), and the unique hash check to read the base table (#3629356: Changing a path alias fails with a duplicate hash error when a disabled redirect exists for the old alias).

Steps to reproduce

  1. In Live, add a redirect from old-path.
  2. Switch to a workspace and delete that redirect, so it goes to the trash.
  3. In the same workspace, add a new redirect from old-path.

Proposed resolution

Add a TrashedRedirectSource constraint to redirects. It reads the hash from the base table, and when the matching redirect is trashed in the active workspace, the form says The source path old-path is used by a redirect in the trash, with a link to the restore form for users who can restore it. The Redirect module's validator is not changed. Nothing changes in Live, where a trashed redirect already has a deleted-[uuid] hash in the base table.

Remaining tasks

Review.

Issue fork trash-3630354

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

amateescu created an issue. See original summary.

amateescu’s picture

Status: Active » Needs review
amateescu’s picture

Issue summary: View changes

Updated the approach in the MRs and the issue summary.

plach’s picture

Status: Needs review » Reviewed & tested by the community

Looks good and works well, thanks!

  • amateescu committed e90ecd74 on 3.1.x
    fix: #3630354 A new redirect fails to save when a redirect trashed in...

  • amateescu committed cba72baf on 3.x
    fix: #3630354 A new redirect fails to save when a redirect trashed in...
amateescu’s picture

Status: Reviewed & tested by the community » Fixed

Merged into 3.1.x and 3.x, thanks for testing!

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.