Dupe error when trying to update an alias if you have changed the pattern and keeping old alias.
(Statement may not make much sense, not really sure how to explain exactly in words. It will make sense when you follow my steps on how to replicate the issue.)
Error:
user warning: Duplicate entry 'user/adminn-' for key 2 query: INSERT INTO url_alias (src, dst, language) VALUES ('user/1', 'user/adminn', '') in /Users/jonathan/Sites/sonymultisite/modules/path/path.module on line 112.
Replicating the issue(Assuming you have a fresh install):
- Enable PathAuto
- Go to 'admin/build/path/pathauto'
- Under General settings select 'Create a new alias. Leave the existing alias functioning.'
- Click 'Save'
- Go to 'user/1/edit'
- Click 'Save'
- Go to 'admin/build/path/pathauto'
- Double check "Under General settings select 'Create a new alias. Leave the existing alias functioning.'"
- Under 'User path settings' change 'Pattern for user account page paths' to 'user/[user-raw]
- Click 'Save'
- Go to 'user/1/edit'
- Click 'Save'
- Go to 'user/1/edit'
- Click 'Save'
Tracked it down to:
if ($op == 'update' or $op == 'bulkupdate') {
if (variable_get('pathauto_update_action', 2) == 0) {
// Do nothing
return '';
}
$update_data = _pathauto_existing_alias_data($src);
$pid = $update_data['pid'];
$old_alias = $update_data['old_alias'];
}
The only thing i can think of is _pathauto_existing_alias_data taking another parameter, like path maybe.
Not sure I do not know enough about the inter-workings of pathauto to know for sure.
Comments
Comment #1
edhaber commentedI've been having the same problem.
It looks like the path system is selecting the first url alias that was created for a node not the latest.
And when pathauto is checking to see if the alias already exists it only checks the first alias.
So you have
The path system will always link node/1 to 'home' not 'front-page' that you created later and pathauto will only check to see if the new path is equal to 'home' and then try to add another alias.
I think we might need to check an array of aliases to see if this one is already used, and we might need to remove the aliases and re-add them to update the order in which they appear in the table.
-Ed
Comment #2
reaneyk commentedsubscribing...
Comment #3
gregglesI think this is a duplicate of #228792: ERROR: user warning: Duplicate entry IN: site/modules/path/path.module on line 106 but I don't really know...