The nodereference module does not pass the node's language to the url() function, resulting in the system path being used for the [field_foo-path] token instead of the aliased path.

I've tested this with a "vanilla" D6 Pressflow site with CCK 3.0-alpha3. Modules needed:
pathauto
token

Steps to reproduce:

1. Create a content type "parent" with multilingual support "enabled with translation".
-- Set up pathauto pattern for this type:
DEFAULT PATH PATTERN FOR PARENT (APPLIES TO ALL PARENT NODE TYPES WITH BLANK PATTERNS BELOW):
"[title-raw]"

2. Edit the default "page" content type, and add a CCK nodereference field. Set the "Parent" node type as the content type that can be referenced.
-- Edit the pathauto pattern for the page node type:
DEFAULT PATH PATTERN FOR PAGE (APPLIES TO ALL PAGE NODE TYPES WITH BLANK PATTERNS BELOW):
"[field_parent_nodereference-path]/[title-raw]"

3. Set up at least 2 languages. (Here I'm using English as the default, and German as another language with a "de" path prefix.
-- Use the "path prefix with language fallback" option.

3. Now create a parent node, in English, making sure its alias is set correctly. (I called mine "Test English Parent," resulting in the "test-english-parent" path alias.)

4. Translate that node into German, keeping the pathauto setting checked. (I called mine "Test German Parent," resulting in a "test-german-parent" path alias.) Note that the path alias will only be active when viewing the node with the "de" language prefix. This is normal behavior. Viewing the path without the alias results in a "Page not found" error.

4. Create a Page node in English, selecting the English Parent node in the nodereference field. I called mine "child page." It's path alias should be "test-english-parent/child-page."

5. Translate this page into German, keeping the pathauto alias box checked. I titled this "german-child-page." (Note that CCK should automatically switch its node reference value to the german parent translation.)

Here's the problem. Visit the node at "/de/node/4", then click the "View" tab (which links to the aliased path, instead of the system path). Notice that the alias generated is "node/2/german-child-page".

This causes an issue where depending on from which language the node alias is updated, a different token will be generated for the path. Ex: performing the "update URL alias" operation at "admin/content/node" without the language prefix in the path will result in the token being "node/2". Performing this operation while browsing with the "de" path alias results in the token being "de/test-german-node", making the full path "/de/de/test-german-node".

I would not expect the path prefix to be a part of the path token.

CommentFileSizeAuthor
#1 node-path-raw_1794812_1.patch2.88 KBjessehs
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jessehs’s picture

This patch adds an intermediary function (_nodereference_nodes($nid)) into _nodereference_titles($nid), breaking out the actual db query, so it can get the language field in the same step. It also adds the _nodereference_language($nid) function, which also calls _nodereference_nodes.

This newfound language is turned into an object, and passed to the url() function while generating the token value. This seems to fix the problem!

Please review.

jessehs’s picture

Status: Needs work » Needs review
jessehs’s picture

Title: [node-path-raw] token does not use translated alias, resulting in "node/x" path instead of aliased path » [field_foo-path] nodereference token does not use translated alias, resulting in "node/x" path instead of aliased path

(Updating title to the correct token name.)

fraweg’s picture

Hello,

I have the same issue with drupal 7. Is there also patch for drupal 7?

Best regards
Frank