Redirects not deleted on alias creation on monolingual sites

Created on 26 July 2023, over 1 year ago
Updated 22 August 2024, 3 months ago

Problem/Motivation

On monolingual sites, created redirects are in undefined language. So when a new alias is created with that source url, we attempt to delete the redirects with that source url in English, but none are found because they are UND.

Steps to reproduce

1. On monolingual site, create a redirect from /redirect to /home.
2. Create a new basic page with alias /redirect

Expected:
The /redirect redirect has been deleted.

Current:
The /redirect redirect has NOT been deleted.

Proposed resolution

We have two options here.

1- The proper one IMHO is ensuring that redirects are created in the default language instead of undefined. The cons is that we should upgrade UND to English in all redirects, but I'm not sure if it's safe to assume that is correct with legacy ones from D6/D7 migrated sites.

2- Update redirect_path_alias_insert/update to call

  redirect_delete_by_path($path_alias->getAlias(), \Drupal\Core\Language\LanguageInterface::LANGCODE_NOT_SPECIFIED, FALSE);

when the $path_alias->language() is equal to the default site language.

Remaining tasks

Decide if we should go with 1 or 2 from the proposed solutions.

User interface changes

None.

API changes

Data model changes

๐Ÿ› Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain penyaskito Seville ๐Ÿ’ƒ, Spain ๐Ÿ‡ช๐Ÿ‡ธ, UTC+2 ๐Ÿ‡ช๐Ÿ‡บ

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024