deletion of redirects for a path alias's new alias only happens for update if redirect creation for alias changes is enabled

Created on 9 July 2025, 2 months ago

Problem/Motivation

redirect_path_alias_insert() takes care of deleting any redirects which have the same source as a path alias that is being created. This is to ensure that the path alias actually works.

However, redirect_path_alias_update() only does this if 'auto_redirect' is enabled in the settings:

function redirect_path_alias_update(PathAliasInterface $path_alias) {
  $config = \Drupal::config('redirect.settings');
  if (!$config->get('auto_redirect')) {
    return;
  }

  /** @var \Drupal\path_alias\PathAliasInterface $original_path_alias */
  $original_path_alias = $path_alias->original;

  // Delete all redirects having the same source as this alias.
  redirect_delete_by_path($path_alias->getAlias(), $path_alias->language()->getId(), FALSE);

Steps to reproduce

Proposed resolution

Deletion of redirects with the same source should happen for updated path aliases regardless of the auto redirect setting.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇧United Kingdom joachim

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

Comments & Activities

Production build 0.71.5 2024