System path redirects create redirect loop

Created on 5 February 2024, 10 months ago
Updated 8 February 2024, 10 months ago

Problem/Motivation

Our site uses Pathauto to create aliases for our nodes. Some of our Pathauto patterns for content types rely on where the node is in a menu tree. There are times we will create content and not put it in a menu until it has been approved. This temporarily leaves the system path (/node/[node-id]) the only alias for the content, and once we place the content in the menu, our final alias is created.

Our site settings for redirects are as follows:

  • Automatically create redirects when URL aliases are changed = TRUE

Our site settings for alias update actions are as follows:

  • Create a new alias. Delete the old alias = TRUE

Now, when we finally put our content in the menu, a redirect loop happens since it creates a redirect using the system path.

Proposed resolution

To bypass this specific case, I wrote a patch to check if the $original_path_alias is the $system_path. If this is the case, then do not create the redirect.

I tried going through the current open issues to see if this had already been reported. I couldn't find anything, but if this happens to be a duplicate, please close this issue. Thanks.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @anthonygray47
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    I am also encountering this on our site. I have pathauto installed. It was added later after a bunch of products were already created with urls such as `/product/2398`. When I go to enable automatic aliases for those products a redirect is automatically created for the path, creating an infinite loop.

    While the redirect UI to add a redirect validates these issues and refuses to create aliases that would cause infinite loops it seems it's missing validation when redirects are created programmatically.

    A patch to do this validation when redirects are created automatically is needed to prevent this from happening. The currently posted patch does not address this as it only checks for node paths.

  • Issue was unassigned.
  • πŸ‡ΊπŸ‡ΈUnited States rhovland Oregon

    Ok I have information about how to reproduce this.
    If you have automatic redirect creation enabled and have saved an entity with the url alias set to the system path for the entity. Go back and change it to something else. A redirect will be created that results in an infinite redirect loop.

    Eg:
    Url alias for a product set to /product/1465 changed to /product/1465-a-pretty-name

Production build 0.71.5 2024