The first lines of system_tokens() are the following:

 $url_options = array('absolute' => TRUE);
  if (isset($language)) {
    $url_options['language'] = $language;
  }
$langcode = (isset($language) ? $language->language : NULL);

The variable $language is not a formal parameter of the function (which is an implementation of hook_tokens(), nor is a local variable defined from the function.

As suggested by manimejia, the function is missing the code line

  global $language;

at the beginning.

Comments

shyamala’s picture

Version: 7.x-dev » 8.x-dev

Tagging

shyamala’s picture

edit tag

shyamala’s picture

StatusFileSize
new502 bytes

Attaching patch for D7

shyamala’s picture

StatusFileSize
new502 bytes

Patch for D7

dave reid’s picture

Status: Active » Needs work
Issue tags: +token

The logic of this section is incorrect. We need to duplicate the same logic from the beginning of node_tokens().

  $url_options = array('absolute' => TRUE);
  if (isset($options['language'])) {
    $url_options['language'] = $options['language'];
    $language_code = $options['language']->language;
  }
  else {
    $language_code = NULL;
  }
  $sanitize = !empty($options['sanitize']);
dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new2.72 KB

Patch against 8.x and 7.x that brings this behavior in line with the rest of the core token functions. No API or parameter changes.

eaton’s picture

Status: Needs review » Reviewed & tested by the community

This one is kind of a no-brainer. Obvious oversight, subtle repercussions when people try to use multilingual tokens, and an easy fix. I've not tried writing any tests against the language systems, but would it make sense for us to put some together? Hard-code a set of translations, set the locale, and test to ensure the tokens come up in the right language? For the time being the patch works nicely, though.

dries’s picture

Status: Reviewed & tested by the community » Fixed

Good catch, and good fix. Committed to 7.x and 8.x. Thanks.

webchick’s picture

Issue tags: +Needs backport to D7

Fixing tag.

Status: Fixed » Closed (fixed)
Issue tags: -token, -Needs backport to D7

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

Anonymous’s picture

Issue summary: View changes

Fixed a typo.