To reproduce:

Create a node and give it an alias.

Now edit the node; change the path alias and hit Preview. Now hit save. The old alias won't be removed, and the new one will be added.

This only happens if you Preview the node *after* changing the URL alias. Otherwise the old alias gets changed, as expected.

Note also that if you now edit the node again and change the alias back (but without hitting Preview) you get a Duplicate entry PHP error, which is probably #228792: ERROR: user warning: Duplicate entry IN: site/modules/path/path.module on line 106 or similar.

Originally when I came across this I thought it was a problem with pathauto, but the problem persisted after disabling that module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gpk’s picture

FileSize
1.22 KB

The problem is that in http://api.drupal.org/api/function/path_form_alter/6 the pid form element is populated with the pid corresponding to the path specified in the node form, not the original path from the database.

Patch for D6 attached which seems to do the trick. Same fix should also work for D7 (once updated for DBTNG).

gpk’s picture

Status: Active » Needs review
gpk’s picture

FileSize
1.22 KB

Cleaned patch.

gpk’s picture

Version: 6.13 » 7.x-dev
FileSize
1.29 KB

And for 7.x.

moshe weitzman’s picture

Looks quite right to me. Could do with a review from someone like greggles or chx.

jromine’s picture

Status: Needs review » Needs work

The last submitted patch failed testing.

gpk’s picture

Version: 7.x-dev » 6.x-dev
Status: Needs work » Needs review
FileSize
1.21 KB

It looks as if the new path API in 7.x has fixed this in a very slightly different way (by using the node's nid rather than its alias to find the relevant pid via the new path_load() API function - see http://api.drupal.org/api/function/path_form_alter/7). [this line clarified Jun 9, 2010]

Setting version back to 6.x for consideration.

This patch is the same as #3 but with a typo in a comment corrected.

lyricnz’s picture

Bug still exists in D6. Patch works, including replacing only the most recent alias when there are multiple. Reroll

gpk’s picture

Since this is just a re-roll and we have a green light can you set status to RTBC? I'd do it but essentially it's my patch...

gpk’s picture

#9: path_node_preview-543608.patch queued for re-testing.

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.