Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In hook_tokens(), the chainable token replacements overwrite all previously set token replacements:
if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) {
$replacements = $token_service->generate(/* snip */);
}
In practice, such as in node_tokens(), it looks like this:
if ($author_tokens = $token_service->findWithPrefix($tokens, 'author')) {
$replacements += $token_service->generate(/* snip */);
}
Comment | File | Size | Author |
---|---|---|---|
#2 | drupal-2865757-2.patch | 1.44 KB | kristiaanvandeneynde |
Comments
Comment #2
kristiaanvandeneyndeNot really a bug report, but can easily lead to bugs because of its use as an example.
Comment #3
dawehnerNice catch. There is not really anything to test here.
Comment #4
alexpottCommitted and pushed 626ea42 to 8.4.x and 588d5e1 to 8.3.x. Thanks!
As a docs fixed committed to 8.3.x