Redirects not deleted on alias creation on monolingual sites

Created on 26 July 2023, 11 months ago
Updated 12 June 2024, 16 days 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

RTBC

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.69.0 2024