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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | i18n-648348.patch | 1 KB | Pisco |
Comments
Comment #1
Pisco commentedThis reports the same issue: #431746: original node path replaced after translating node, both have same path not translated terms
Comment #2
Pisco commentedSCNR before going to bed. The patch seems to work, please cross-check!
Comment #3
Pisco commentedComment #4
rbl commentedIt's not working for me =(
Ricardo
Comment #5
Pisco commentedHello Ricardo
Could you please provide a bit more info on how you tested it and what exactly went wrong?
Comment #6
Bilmar commentedsubscribing
Comment #7
Anonymous (not verified) commentedWorks fine for me! Great patch.
Comment #8
jose reyero commentedYes, this makes a lot of sense.
Committed a modified version (disable content selection before any update, just reset it after updates).
Thanks
Comment #9
Woggers commentednoticed this wasn't included in the new update released yesterday? Any reason why or was the patch just submitted too late?
Comment #11
hobo commentedI'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)
Comment #12
hobo commentedComment #13
vthirteen commentedsubscribe
Comment #14
vthirteen commentedComment #15
loominade commentedsubscribing
Comment #16
jdanthinne commentedI 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
Comment #17
gnindl commentedHave a look at the patch here #897850: Support for URL alias synchronization per content type maybe it helps you.
Comment #18
benmirkhah commentedSubscribe
Comment #19
roderik#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.