Initial conditions:
Set Update action as 'Create a new alias. Delete the old alias.'
Set Category path settings as [vocab-raw]/[catpath-raw]
Set 'Create feed aliases' for taxonomies
Bulk update taxonomies if not aliased yet.
Steps to reproduce:
1. Go to /admin/content/taxonomy
2. Show terms listing of selected vocabulary (my was without hierarchy)
3. Edit category name
4. Save changes
Expected result: Old alias deleted updated to new alias, new feed alias created. Changes also saved in {url_alias_extra}
Actual result: Old alias didn't changed, old feed alias doubled in {url_alias_extra}. No changes in {url_alias_extra}
Additional info:
To make aliases work as expected we need to resave term without change of the name. {url_alias} is then properly changed but {url_alias_extra} is not properly updated. In watchdog we have error about duplicate primary key. This is because of code in _pathauto_set_alias():
// Skip replacing the current alias with an identical alias
if ($old_alias != $dst) {
path_set_alias($src, $dst, $pid, 1, 10);
$new_pid = db_result(db_query("SELECT pid FROM {url_alias} WHERE src = '%s' and dst = '%s'", $src, $dst));
db_query("INSERT INTO {url_alias_extra} (pid, dst, entity_type, entity_id, created_by) VALUES (%d, '%s', '%s', %d, '%s')", $new_pid, $dst, $entity_type, $entity_id, 'Pathauto');
In this case $new_pid already exists, so no INSERT is done. I think there should be also an UPDATE if $new_pid exists.
Very confusing result we got when we edit name of the term and revert it to the old one (or change again). After second change of the name we got aliases from the first change.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | pathauto.module.patch | 1.79 KB | vito_swat |
Comments
Comment #1
vito_swat commentedChanging 'Category path settings' from [vocab-raw]/[catpath-raw] to [vocab-raw]/[cat-raw] solves the problem with updating names but it's not exactly what I want. Also problem with {url_alias_extra} is still present:
Duplicate entry '14899' for key 'PRIMARY' INSERT INTO url_alias_extra (pid, dst, entity_type, entity_id, created_by) VALUES ...Comment #2
gregglesI just happened on this today and I'm not sure that these two errors are related. url_alias_extra is just a tracking system (but I agree, that needs to be fixed as well).
Comment #3
vito_swat commentedI guess it's unrelated because I reproduced error with duplicates without [catpath] token. I'll post another issue for this: http://drupal.org/node/198413
Comment #4
7PEPO7 commentedHey. First sorry for my bad english.
I found a solution. In
pathauto.modulefile in functionpathauto_token_valuesto calculate values for$catpathand$catpath-rawis use functiontaxonomy_get_parents_alland this one usefunction taxonomy_get_term, where results are statically cached. And this is a problem.Solution:
In file
pathauto.modulein functionpathauto_token_valueschange:to
It's help.
Comment #5
vito_swat commented@7PEPO7
I created patch from your suggestions. I added also handling of subcategories aliasing.
Now if you have hierarchy like:
pattern: 'term/[catpath-raw]'
-- level1 -> alias term/level1
-- -- level2 -> alias term/level1/level2
-- -- -- level3 -> -> alias term/level1/level2/level3
and change level1 to 'new':
-- level1 -> alias term/new
-- -- level2 -> alias term/new/level2
-- -- -- level3 -> -> alias term/new/level2/level3
old behavior was to change only alias on level1.
In my opinion we should also change node aliases if they use term related patterns but it could lead to long execution problems.
I carefully tested this patch and i think it's RTBC.
Comment #6
gregglesvito_swat - thanks so much and please pardon my delay.
I did a basic test and it worked so I have committed this to the DRUPAL-5--2 branch. I need to apply it to 6.x as well (hence the status).
Comment #7
vito_swat commentedAnd what do you think of:
I also think that other *path aliases should be updated if parent is updated. Think about i.e. books.
Comment #8
gregglesAs you point out, it is unlikely to work well given that it could potentially require updating thousands (hundreds of thousands+) of nodes. One of the major scalability features of 5.x-2.x was bulk updates that run in configurable sized chunks. This has introduced new problems, but fewer new problems than the old problems..... If we tried to update all affected nodes we would have the first problem of how to figure out which nodes are affected and of course the second problem of updating such a large number of nodes. In summary - I don't think that's something we can/should tackle right now.
Comment #9
gregglesand committed to HEAD.
Comment #10
(not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.