Download & Extend

Custom path aliases getting deleted on language assign action

Project:Language Assignment
Version:6.x-1.2
Component:Code
Category:bug report
Priority:normal
Assigned:Andrew Schulman
Status:active

Issue Summary

Hey there,

I had a number of nodes with manually specified aliases in my site, however, after running language assign on them, their aliases were all changed to the pathauto default option, which was very annoying!

Just posting this to make sure people know about this and it would be nice to have a fix.

Cheers,
Martin

Comments

#1

Priority:major» normal
Assigned to:Anonymous» Andrew Schulman

Thanks for the report. I don't know why this should happen, since Language Assignment doesn't have anything to do with the path alias table. However, I'll look into it this weekend and try to reproduce it.

Can you reproduce this bug on your site? That is, does it happen every time?

#2

Hey, thanks for that.

Sorry but I actually had this happen to me on a 2-days-pre-launch production site, so I doubt I can test it there any more ;) One thing I remember though it that the paths have been originally created in English I think, same as the content, but when I assigned Language-Neutral to all the nodes, the paths were gone too. (On the other hand, I think some of the paths were created as language-neutral, and these were gone too.. anyway).

#3

Ah hah... OK... I didn't even know that path aliases had a language. Thanks, I'll look into it.

#4

I just tried this on my development site. It looks like a Drupal bug, and it's a mess, all right.

I have a few path aliases defined on a node. When I change the node language:

  • If the new language is language neutral, then some of the aliases defined for that node get changed to language neutral.
  • If the new language is not language neutral, and is different from the language of all of the existing path aliases, then the old path aliases are left as they are, but a new copy of one of them gets created, in the new language. Which one gets copied seems to be random each time.
  • And, if the new language is the same as the language of some of the node's aliases, then all of the aliases get deleted, as you reported.

Quite a mess, but Language assignment isn't doing any of it. LA just calls node_mass_update(), a Drupal API function, to change the node languages. Obviously when that happens, some code somewhere else is also changing the path alias languages in inconsistent ways. I'll look into this more and get back to you.

#5

By the way, there's also the question of what Language assignment should be doing with the path aliases, when the node language changes. What probably makes sense is to change the path aliases' language to the new node language. But there are other ways it could be handled, such as creating new aliases in the new language. That then raises the question of whether and how to allow the user to decide. Please let me know what you think.

It also points out (I never noticed any of this stuff before, because I never noticed that path aliases have languages) that there's no bulk update form for URL aliases at admin/build/path. If there were, then the above wouldn't matter as much. This is a new feature that I might add in the next release.

#6

hey, looking like good progress there :) I think that the default way, if there should be one, would be to adjust the aliases accordingly with the nodes, to the new language. Although I have to admit as I performed the one-off operation on my site already I don't really need a fix anymore, was just reporting this for your benefit ;)

#7

There's some argument over what's the right thing to do with the path aliases when the node language changes: see #541802: Let path_nodeapi reuse the current path alias language on update and #347265: URL aliases not working for content not in default language. I don't really know what the best answer is.

What's clear is that when Language assignment calls node_mass_update() to change the node language, a call to path_nodeapi(..., 'update') and then path_set_alias(..., $language) gets made automatically, after each node's language is set. This is supposed to reset the path alias language to the node language, but as we've seen it doesn't always work right. I'll see if I can nail this down and file a bug report about it.

I can think of a couple of solutions for Language assignment, to mitigate both of these problems.

  1. When the user asks to change the language of some nodes, serve up a new form that lists all of the associated URL aliases and their languages, and ask the user to choose which aliases she wants to change the language of.
  2. Create a URL alias bulk update form, like the node and user bulk update forms, where users can change the alias languages.