Workflow participants provides tokens for existing entity types, however it also specifies "subtypes", which the Token API does not appear to support.

 if ($entity_type->entityClassImplements(EditorialContentEntityBase::class)) {
        $types[$entity_type->id()]['workflow_participants'] = [
          'name' => $this->t('Workflow participants for @type', ['@type' => $entity_type->getLabel()]),
          'description' => $this->t('Tokens for workflow participants.'),
        ];
    ...

These tokens are also added as part of hook_token_info() rather than hook_token_info_alter(), even though they are supplementing the set of tokens provided by the Token module.

These two things combine to form a bug that prevents the block_content token type from receiving its basic information. i.e.

  1. When collecting token information, hook_token_info() is invoked and Workflow Participants ends up adding an entry for $info['types']['block_content']['workflow_participants'].
  2. The alter hooks are run and token_token_info_alter() gets invoked.
  3. It tries to populate a few properties like name for block_content, but sees that the array key already exists, so it assumes that something else already put the correct information there and skips over it, leaving it without a name.

Comments

kevin.dutra created an issue. See original summary.

kevin.dutra’s picture

Status: Active » Needs review
StatusFileSize
new1.33 KB

Here's a test to demonstrate the problem.

Status: Needs review » Needs work

The last submitted patch, 2: token-type-error-2956219-test_only.patch, failed testing. View results

kevin.dutra’s picture

Assigned: kevin.dutra » Unassigned
Status: Needs work » Needs review
StatusFileSize
new3.98 KB

And here's a fix.

Status: Needs review » Needs work

The last submitted patch, 4: token-type-error-2956219-4.patch, failed testing. View results

kevin.dutra’s picture

Status: Needs work » Needs review
StatusFileSize
new4.68 KB
new616 bytes

Oops, and here's a fix for the test I broke.

  • jhedstrom committed 8877a22 on 8.x-2.x authored by kevin.dutra
    Issue #2956219 by kevin.dutra: Token type name is not set for custom...
jhedstrom’s picture

Status: Needs review » Fixed

Great find! Thanks for the fix and the test coverage!

Status: Fixed » Closed (fixed)

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