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.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 988878-system-tokens-fix-language-option.patch | 2.72 KB | dave reid |
| #4 | global-variable-988878-3.patch | 502 bytes | shyamala |
| #3 | global-variable-#988878-3.patch | 502 bytes | shyamala |
Comments
Comment #1
shyamala commentedTagging
Comment #2
shyamala commentededit tag
Comment #3
shyamala commentedAttaching patch for D7
Comment #4
shyamala commentedPatch for D7
Comment #5
dave reidThe logic of this section is incorrect. We need to duplicate the same logic from the beginning of node_tokens().
Comment #6
dave reidPatch 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.
Comment #7
eaton commentedThis 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.
Comment #8
dries commentedGood catch, and good fix. Committed to 7.x and 8.x. Thanks.
Comment #9
webchickFixing tag.
Comment #10.0
(not verified) commentedFixed a typo.