Execute the following code without specifying the clear option:
$node = \Drupal\node\Entity\Node::load($nid);
$result = \Drupal::service('token')->replace(
'[node:field_custom|node:title]',
['node' => $node]
);
Expected Result: The token should be replaced by the corresponding value (e.g., the node title).
Actual Result: The output is the literal string "[node:field_custom]".
Now, execute the code with the ['clear' => true] option:
$node = \Drupal\node\Entity\Node::load($nid);
$result = \Drupal::service('token')->replace(
'[node:field_title_for_yandex_direct|node:title]',
['node' => $node],
['clear' => true]
);
Expected and Actual Result: The output is the correct node title.
Impact:
This behavior indicates that the token_or module only processes the token replacement correctly when the clear option is explicitly set to true. Without this flag, the service fails to substitute the token values as expected, which could lead to inconsistencies and confusion in environments relying on default behavior.
Active
2.3
Code