URL Alias not saving in some cases

Created on 27 June 2016, over 8 years ago
Updated 25 December 2024, about 1 month ago

Problem/Motivation

When trying to set a custom alias for a node that previously had an automatic alias, but for which the pattern was removed, the custom alias does not get saved.

Step to reproduce

  1. Create a content type.
  2. Create a pattern which applies to this content type.
  3. Create a node with an automatic alias.
  4. Remove the pattern.
  5. Edit the node. Notice that the checkbox "Generate automatic URL alias" no longer appears, cause there is no longer a pattern that applies to the content type. Try to set a custom alias and save the node.

Expected result: the alias for the node is changed to the custom alias.

Actual result: the alias has not been changed.

Proposed resolution

Possible solutions:

  • On the widget \Drupal\pathauto\PathautoWidget, set the "pathauto" property explicitly to PathautoState::SKIP when there is no pattern found for the entity.
    Cons
    • May not fix the issue when updating entities using REST?
  • In \Drupal\pathauto\PathautoItem::postSave() also execute the parent's postSave() when there is no pattern found for the entity.
    Cons
    • When setting the pathauto state explicitly to PathautoState::CREATE, it is no longer guaranteed that the existing alias is preserved.

Original report by sukanya.ramakrishnan

Hello,

I am trying to enter a URL alias on an article content and i find that it is not getting updated on the node.
I have the pathauto module installed. I dont have any patterns setup to auto generate any aliases.

Ideally, i would think that the url alias i entered for the article would be saved, but when i debugged, i found that the path module code is not getting executed and pathauto seems to override the path module in this case. I wanted some help to understand how this works. Will really appreciate if someone can throw some light on this.

Thanks
Sukanya

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I just ran into this issue, I haven't used clone or import but due to the fact that pathauto can't use "#" I am using eca to set the path.
    Now i noticed i couldn't set set the url alias manually or with eca, even un-installing path-auto didn't solve the issue because sub-path auto was installed also.
    I had to un-install pathauto and sub-pathauto and than i could manually or with eca set the path alias.

Production build 0.71.5 2024