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 */);
    }
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kristiaanvandeneynde created an issue. See original summary.

kristiaanvandeneynde’s picture

Status: Active » Needs review
FileSize
1.44 KB

Not really a bug report, but can easily lead to bugs because of its use as an example.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice catch. There is not really anything to test here.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 626ea42 to 8.4.x and 588d5e1 to 8.3.x. Thanks!

As a docs fixed committed to 8.3.x

  • alexpott committed 626ea42 on 8.4.x
    Issue #2865757 by kristiaanvandeneynde: Fix wrong example for chained...

  • alexpott committed 588d5e1 on 8.3.x
    Issue #2865757 by kristiaanvandeneynde: Fix wrong example for chained...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.