Remove message_token_info and let Token module define all tokens

Created on 9 August 2021, over 3 years ago
Updated 31 January 2024, about 1 year 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 about 1 year 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
    10 months ago
    Total: 167s
    #197150
  • Pipeline finished with Failed
    10 months ago
    Total: 166s
    #197297
  • Pipeline finished with Canceled
    10 months ago
    Total: 47s
    #197324
  • Pipeline finished with Failed
    10 months ago
    Total: 203s
    #197326
  • Pipeline finished with Failed
    10 months ago
    Total: 207s
    #200188
  • Pipeline finished with Failed
    10 months ago
    #200192
  • πŸ‡³πŸ‡±Netherlands eelkeblok Netherlands πŸ‡³πŸ‡±

    It is a quite a battle to get tests to work with the Token module. I am now running into the fact that Token module seems to be dependent on certain date formats being available.

    As for the dependency, my current thinking is that maybe we should not "hard" require Token module. What that does imply is that we need to make it clear in release notes that if you need tokens derived from messages, you need to install the module.

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

    It always helps to complain (?). I think this should take care of it.

  • Pipeline finished with Success
    9 months ago
    Total: 207s
    #210810
  • πŸ‡³πŸ‡±Netherlands eelkeblok Netherlands πŸ‡³πŸ‡±
  • πŸ‡³πŸ‡±Netherlands eelkeblok Netherlands πŸ‡³πŸ‡±
  • Status changed to Needs review 9 months ago
  • πŸ‡³πŸ‡±Netherlands eelkeblok Netherlands πŸ‡³πŸ‡±
  • Status changed to RTBC 9 months ago
  • πŸ‡¬πŸ‡·Greece vensires

    Using your patch I personally didn't have any issues.
    And thank you very much for your detailed updates though it was a solo effort! I really appreciated it!
    Setting it as RTBC!

  • πŸ‡©πŸ‡ͺGermany Istari

    Works fine for me under a fresh Drupal 10.3.9 environment :)

  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9

    bluegeek9 β†’ changed the visibility of the branch 8.x-1.x to hidden.

  • Pipeline finished with Skipped
    about 2 months ago
    #424643
  • πŸ‡ΊπŸ‡ΈUnited States bluegeek9
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024