- Issue created by @thfalvar
- 🇮🇳India sumit-k
It appears that the issue encountering is related to the [current-user:roles:last] token not being supported because roles:last is not a valid field name within the user entity.
public function processToken(FieldableEntityInterface $entity, $token_entity_type, $argument) { // @todo $entity_type could potentially be retrieved by checking on $entity. $and_or = $this->options['and_or']; $field_names = $this->tokenScan($argument); foreach ($field_names[$token_entity_type] as $field_name => $token) { $replace_values = []; if ($entity->hasField($field_name)) { $field_values = $entity->get($field_name)->getValue(); foreach ($field_values as $field_value) { $replace_values[] = array_values($field_value)[0]; } // Replace and implode with , or + for multiple value management. $replace = implode($and_or, $replace_values); $argument = str_replace($token, $replace, $argument); } } return $argument; }
The provided code snippet shows the processToken function in Drupal, which handles token replacement within entities. In this function, it attempts to retrieve the field values associated with the specified field name from the entity. However, it checks if the entity has a field with the name roles:last, and since this field name does not exist within the user entity, the token replacement does not occur.
- 🇺🇸United States rudy.barrett
I'm running into this issue on a few of my sites and have had to subsequently roll back to 2.0.0 in order to get them to work again. Specifically, it seems to be related to this commit.
https://git.drupalcode.org/project/views_argument_token/-/commit/8732825...That one commit breaks many of my sites' contextual filters.
- 🇨🇦Canada smulvih2 Canada 🍁
@rudy I think I am having the same issue on one of my sites. Will test removing this patch to see if it resolves the issue.
- Status changed to Closed: duplicate
about 1 year ago 9:18pm 16 October 2023