Error message

You need to log in or create an account to access this page.

Hook tokens is not properly taking in langcodes, which results in links for entity translation only passing 'en'.

Comments

sylus’s picture

Attaching patch.

sylus’s picture

Attaching patch.

sylus’s picture

Status: Active » Needs review
StatusFileSize
new2.69 KB

Better guarding.

joseph.olstad’s picture

After applying this patch langcode still defaulting to english even if in other language with properly encoded uuid link.

time for xdebug

sylus’s picture

Just spend the last few hours on this and got it fixed but with quite a few hacks. Will post it here once clean up dpm's.

joseph.olstad’s picture

Shooting in the dark here but I'm guessing something along the lines of:

- 'language' => $languages[$langcode],
+ 'language' => $language->language,

? anyhow, curious to see the fix.

sylus’s picture

Updating patch.

1) token_replace needs to be passed in langcode from filter_preprocess
2) i had to make the replacements variable non-static as with field translation it was always only eventually passing one language (maybe should use drupal_static?)
3) am now calling entity_uri vs node_uri and completely bypassing the uuid_link_entity_url so no doubt have broken support for non node related entities.

However the languages are fully working now in nodes.

sylus’s picture

Whoops had a few more lines could have removed. Here we go.

sylus’s picture

Updating the patch.

skwashd’s picture

Issue summary: View changes
Status: Needs review » Needs work

Thanks for the patch. Overall I'm in favour of this. The whitespace/coder compliance changes while welcomed make it more difficult to read the patch.

There are 2 things I have concerns about.

+++ b/uuid_link.module
@@ -149,16 +149,15 @@ function uuid_link_tokens($type, $tokens, array $data = array(), array $options
-          // We create a dummy node with only nid and language, as an attempt
-          // to get a working URL for the node.
-          $dummy_node = db_select('node', 'n')

Instead of removing these docs they should be retained and updated.

+++ b/uuid_link.module
@@ -255,7 +255,16 @@ function uuid_link_filter_info() {
+  else {
+    $options = array();
+  }

Initialising options as an empty array before the if() block removes the need for the else. You can then also have $options['language'] = $languages[$langcode]; in the if() block.