Remove uses of the [user:name] token

Created on 29 November 2019, over 4 years ago
Updated 15 February 2023, over 1 year ago

Problem/Motivation

Part of #2716163: [META] Remove deprecated classes, methods, procedural functions and code paths outside of deprecated modules on the Drupal 9 branch →
Removal of deprecated [user:name] token makes comment, file, node, and user token tests to fail.

Proposed resolution

We decided to keep the token around, since deprecating it would be too disruptive at this moment.
We will however remove all usage of token [user:name] in core itself.

Remaining tasks


create patch and commit

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Needs work

Version

10.1 ✨

Component
User module  →

Last updated 1 day ago

Created by

🇫🇷France andypost

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

Comments & Activities

Not all content is available!

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

  • 🇫🇷France andypost
    1. +++ b/core/lib/Drupal/Core/Utility/Token.php
      @@ -371,16 +371,16 @@ public function generate($type, array $tokens, array $data, array $options, Bubb
      -   *     'author:name' => '[node:author:name]',
      +   *     'author:name' => '[node:author:account-name]',
      

      I think key should also changed to 'author:account-name'

    2. +++ b/core/lib/Drupal/Core/Utility/Token.php
      @@ -371,16 +371,16 @@ public function generate($type, array $tokens, array $data, array $options, Bubb
      -   *   $results == array('name' => '[node:author:name]');
      +   *   $results == array('name' => '[node:author:display-name]');
      

      that's inconsistent with above(

    3. +++ b/core/modules/system/tests/src/Kernel/Token/TokenReplaceKernelTest.php
      @@ -62,6 +62,8 @@ public function testClear() {
           // No user passed in, should be untouched.
      +    $source .= '[user:account-name]';
      +    // Keep old test to token also.
           $source .= '[user:name]';
      

      it may need separate legacy/deprecation test

  • 🇮🇳India adeshsharma Bhopal

    Added changes mentioned in the above comment.

  • Status changed to Needs review over 1 year ago
  • 🇮🇳India adeshsharma Bhopal
  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    Please include an interdiff with patches

    Your patch seems to be missing all the changes

  • 🇧🇷Brazil murilohp

    Here's a new patch based on #47, and regarding #48:

    it may need separate legacy/deprecation test

    I wasn't able to address this one, according to #46, we'll need a followup to properly deprecate the old token, and since the code is not deprecating anything right now, I think we can have this test created on the followup issue, what do you think?

    Moving back NR

  • Status changed to Needs review over 1 year ago
  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    That makes sense to me.

    Tagging for a followup for that ticket to be created.

Production build 0.69.0 2024