Re-implement hook_tokens()

Created on 4 June 2015, almost 10 years ago
Updated 8 September 2024, 6 months ago

Problem/Motivation

The body of hook_tokens() was commented out early in the porting process and hasn't been updated since.

Proposed resolution

Uncomment and update hook_tokens().

Remaining tasks

Create patch.
Create test for flag token functionality.

User interface changes

None.

API changes

Flag tokens would work again.

πŸ› Bug report
Status

Needs work

Version

4.0

Component

Token integration

Created by

πŸ‡ΊπŸ‡ΈUnited States socketwench

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

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.

  • πŸ‡ΉπŸ‡­Thailand AlfTheCat

    Patch from #43 applies but it seems only to work for node flags. I'm trying to use a token in a flag link on a custom ECK entity and it's not working.

  • First commit to issue fork.
  • Merge request !72Re-implement hook_tokens() β†’ (Open) created by vensires
  • πŸ‡¬πŸ‡·Greece vensires

    Created MR!72 based on #44 πŸ› Re-implement hook_tokens() Needs work without any other change. Useful for the automated testing overview.

  • Pipeline finished with Failed
    6 months ago
    Total: 706s
    #276819
  • ivnish Kazakhstan

    MR needs rebase

  • Pipeline finished with Failed
    4 months ago
    Total: 238s
    #326927
  • πŸ‡¬πŸ‡·Greece vensires

    I am almost totally sure I didn't do the rebase correctly. Will retry later.

  • πŸ‡¬πŸ‡·Greece vensires

    Seems hook_tokens() was completely removed by commit 40257ad528474fa355cc91005f6fafd31a5435d7 in order to fix πŸ“Œ All coding standard fixes Active .
    I will add it back again but we will have to test whether in latest 8.x.4.x versions the tokens have been address in another more dynamic way.

  • Pipeline finished with Failed
    4 months ago
    Total: 199s
    #327303
  • πŸ‡¬πŸ‡·Greece vensires

    I have fixed the MR and reimplemented the changes manually to be as sure as I can that I got it all correctly. Please validate and try thoroughly!

    I also take the opportunity and remove the "Needs tests" tag since there are various comments that tests are fixed etc previously in this issue. The current tests have some @todo comment which someone might like to consider and maybe add the "Needs tests" tag back again.

  • First commit to issue fork.
  • Pipeline finished with Failed
    4 months ago
    Total: 239s
    #337610
  • Pipeline finished with Failed
    4 months ago
    Total: 153s
    #337712
  • Pipeline finished with Success
    4 months ago
    Total: 158s
    #337720
  • Pipeline finished with Success
    4 months ago
    Total: 156s
    #337741
  • Pipeline finished with Success
    about 2 months ago
    Total: 200s
    #403556
  • πŸ‡¬πŸ‡·Greece vensires

    I fixed the PHPCS issues. There are still some PHPSTAN issues but I'm not sure they are related to this issue's code.
    I also upload the latest patch based on the MR.

  • πŸ‡¨πŸ‡­Switzerland berdir Switzerland

    drupal core is about to deprecate hook_hook_info() (the issue is RTBC) and the tokens.inc file: https://www.drupal.org/node/3489765 β†’

    For now implementations, as a minimal fix, move the hooks into the .module file or already use the new OOP hooks linked there with #LegacyHook files in .module.

  • Pipeline finished with Success
    about 2 months ago
    Total: 161s
    #403665
  • πŸ‡¬πŸ‡·Greece vensires

    Thank you @berdir for the update. I wasn't aware of the deprecation change. In my latest commit I transferred the hook implementations to the main module file as a first step short-term fix.

    Next thing to do is to follow the guidelines and add the [#LegacyHook] attribute. If anyone else tries to address it, this article by dev.to might be helpful.

  • πŸ‡¬πŸ‡·Greece vensires

    Also uploading the latest diff from the MR as patch.

Production build 0.71.5 2024