Remove message_token_info and let Token module define all tokens

Created on 9 August 2021, almost 3 years ago
Updated 9 February 2024, 5 months ago

Problem/Motivation

Currently, the Message module defines its own tokens: message_token_info. This prevents the Token module for automatically defining base fields added by custom modules – or bundle fields. Only fields that are FieldConfig will be generated.

Customizations can still be added, like we do in Commerce: https://git.drupalcode.org/project/commerce/-/blob/8.x-2.x/modules/order...

Providing the "type" cancels Token's automatic generation

    'types' => ['message' => $type],

See

* #2493567: Allow field tokens also for base fields β†’
* https://git.drupalcode.org/project/token/commit/850e7fb

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Needs work

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.x + Environment: PHP 8.1 & MySQL 8
    last update 5 months ago
    30 pass, 2 fail
  • πŸ‡³πŸ‡±Netherlands eelkeblok Netherlands πŸ‡³πŸ‡±

    I see that the tests change the used tokens from [message:author:name] to [message:uid:entity:name] and that the hook_token is completely removed. This looks like a BC-breaking change. I'm not sure, but maybe we can somehow keep them functional while also giving a deprecation warning (I think this may be possible by implementing the token in hook_token but not actually defining them, i.e. still leaving out hook_token_info.

  • πŸ‡³πŸ‡±Netherlands eelkeblok Netherlands πŸ‡³πŸ‡±

    Actually, why do we want to leave this to token module? It is not a dependency, and I am unsure whether we should want it to be. I am currently on a quest to get the variant values of messages to be available as tokens and thought this might do it, but no luck.

  • πŸ‡³πŸ‡±Netherlands eelkeblok Netherlands πŸ‡³πŸ‡±

    I wasn't entirely sure why this is happening. In case you are curious as well, this is where token module is deciding not to do any base field tokens when a module defines its own tokens: https://git.drupalcode.org/project/token/-/blob/8.x-1.x/token.tokens.inc... (Still not 100% in the clear why it does that, but there's probably a good reason).

    In the spirit of DRY, I guess a lot is to be said for actually depending on token module.

    • We'll need a dependency on token module in info.yml (and concencus this is what we want to do..?)
    • Wel'll need an update hook to enable token module if it is not enabled
    • We'll need to check which of our own tokens can be removed completely because they are now defined by token module
    • We'll need to check which of our own tokens have equivalents in the default token implementation and deprecate them, presumably by issuing a deprecation warning when they are used
  • Pipeline finished with Failed
    13 days ago
    Total: 167s
    #197150
  • Pipeline finished with Failed
    13 days ago
    Total: 166s
    #197297
  • Pipeline finished with Canceled
    13 days ago
    Total: 47s
    #197324
  • Pipeline finished with Failed
    13 days ago
    Total: 203s
    #197326
  • Pipeline finished with Failed
    9 days ago
    Total: 207s
    #200188
  • Pipeline finished with Failed
    9 days ago
    #200192
Production build 0.69.0 2024