Using i18nsync and i18ntaxonomy breaks the automatic generation of url aliases by Pathauto, specifically when using a token like [termpath] or [termpath-raw].

The Condition

Assume the following conditions:

  • you have translated nodes
  • you have hierarchical taxonomies and translations thereof
  • you let Pathauto automagically generate url aliases using tokens like this: [termpath]/[title]
  • you use i18nsync to synchronize some fields between translated nodes

The Error

Lets say that you are editing a node which has translations and your current interface language is English. When you save the node after an edit, i18nsync will synchronize the translations as configured. The synchronization causes each translation to be loaded (node_load), synchronised and saved again (node_save). Saving the node after a sync causes Pathauto to regenerate/update the url alias. Remember that we have translated taxonomies, so that the result of [termpath]/[title] will depend on the translation of taxonomy term assigned to a node. At some point Pathauto will do
$parents = taxonomy_get_parents_all($category->tid);
(pathauto.module 6.x-1.2 line 129)

taxonomy.module line 755 in turn will do this:
$result = db_query(db_rewrite_sql('SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid WHERE h.tid = %d ORDER BY weight, name', 't', 'tid'), $tid);

this again will trigger hook_db_rewrite_sql implemented by i18ntaxonomy (i18ntaxonomy_db_rewrite_sql in i18ntaxonomy.module line 292). The rewritten query will look like this:

SELECT t.tid, t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON h.parent = t.tid   WHERE (t.language ='en' OR t.language ='' OR t.language IS NULL) AND (  h.tid = %d )ORDER BY weight, name

Note the WHERE clause that filters for taxonomy terms that are not in the current language or don't have a language assigned and are therefore presumed language independent.

If the term of the node that is currently processed is French, then Pathauto will be looking for ancestor terms of that French term, but i18ntaxonomy will filter them all out, because, reasonably enough, the terms ancestor terms are all in French.

Possibly a Solution

I noticed that i18ntaxonomy_db_rewrite_sql calls 18n_selection_mode which is in i18n.module line 348. The description says

Allows several modes for query rewriting and to change them programatically.

I imagine a solution would be to set 18n_selection_mode to

off = No language conditions inserted

for the duration of the sync and afterwards setting it back to what it was. I will try this at home :-) and provide a patch if it leads to success.

CommentFileSizeAuthor
#2 i18n-648348.patch1 KBPisco

Comments

Pisco’s picture

Pisco’s picture

StatusFileSize
new1 KB

SCNR before going to bed. The patch seems to work, please cross-check!

Pisco’s picture

Status: Active » Needs review
rbl’s picture

It's not working for me =(

Ricardo

Pisco’s picture

Hello Ricardo

Could you please provide a bit more info on how you tested it and what exactly went wrong?

Bilmar’s picture

subscribing

Anonymous’s picture

Works fine for me! Great patch.

jose reyero’s picture

Status: Needs review » Fixed

Yes, this makes a lot of sense.

Committed a modified version (disable content selection before any update, just reset it after updates).

Thanks

Woggers’s picture

noticed this wasn't included in the new update released yesterday? Any reason why or was the patch just submitted too late?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

hobo’s picture

I'm seeing a similar if not the same issue..

When i turn on taxonomy term sync.. (between two languages)
i can not enter the same url alias for different languages.

For example
french page = fr/blahblah
english page = en/blahblah

everything works fine until you sync taxonomies..
Now if you go in and edit the english node and press save it will revert to node/888 url. It will not allow blahblah as the alias (it probably thinks that the alias already exists.. though its in a different language)

if you turn off taxonomy terms sync everything is back to normal. (you can have the same alias in different languages)

hobo’s picture

Status: Closed (fixed) » Active
vthirteen’s picture

subscribe

vthirteen’s picture

Version: 6.x-1.2 » 6.x-1.4
loominade’s picture

subscribing

jdanthinne’s picture

I have the same problem. After investigating a lot thinking Pathauto was the problem, I've discovered that the bug was happening only after the activation of the Synchronize feature, even without i18ntaxonomy.
If it can help, I managed to reproduce the bug here : http://drupal.org/node/358722#comment-2871858

gnindl’s picture

Status: Active » Needs review

Have a look at the patch here #897850: Support for URL alias synchronization per content type maybe it helps you.

benmirkhah’s picture

Subscribe

roderik’s picture

Status: Needs review » Closed (fixed)

#11: your problem is not caused by 1i8n but by a Drupal Core bug (which indeed isn't triggered when you turn off the i18nsync module).
See #269877: path_set_alias() doesn't account for same alias in different languages

Based on this, I guess this can be reset to the status as of #10.