- π¦πΊAustralia darvanen Sydney, Australia
No activity for many years and Drupal 7 is now out of support. Marking out of date.
So in the _token_filter_filter_tokens
function, there is a break;
called when the backtrace loop finds a call from field_default_view
. This is done via a switch. Inside the switch statement, the entity that was part of the original call is loaded so that the tokens can be properly replaced.
This doesn't work correctly when the entity, that has the token, is being rendered via a parent entity with an entity reference. The backtrace foreach loop ends up finding the field_default_view
for the parent entity and loads that one up for token replacement.
I think this can easily be fixed by just replacing
case 'field_default_view':
// field_default_view($entity_type, $entity) is fairly reliable since
// it is called by both field_attach_view() and field_view_field().
$entity_type = $caller['args'][0];
$entity = $caller['args'][1];
$token_type = token_get_entity_mapping('entity', $entity_type);
$data[$token_type] = $entity;
// Use the proper language code that field_default_view() was called with.
if ($langcode = $caller['args'][4]) {
$language_list = language_list();
if (!empty($language_list[$langcode])) {
$options['language'] = $language_list[$langcode];
}
}
break;
with
case 'field_default_view':
// field_default_view($entity_type, $entity) is fairly reliable since
// it is called by both field_attach_view() and field_view_field().
$entity_type = $caller['args'][0];
$entity = $caller['args'][1];
$token_type = token_get_entity_mapping('entity', $entity_type);
$data[$token_type] = $entity;
// Use the proper language code that field_default_view() was called with.
if ($langcode = $caller['args'][4]) {
$language_list = language_list();
if (!empty($language_list[$langcode])) {
$options['language'] = $language_list[$langcode];
}
}
break 2;
I haven't done any extensive testing, but I can't see the drawback of breaking out of both the switch and the foreach as soon as the first field_default_view caller is found.
Closed: outdated
1.0
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
No activity for many years and Drupal 7 is now out of support. Marking out of date.