Use the user display name instead of the username on the user authoring information in the node edit form

Created on 19 November 2020, over 4 years ago
Updated 27 January 2023, over 2 years ago

Problem/Motivation

When editing a node, the authoring information displays the user account name, the display name should be used instead.

Steps to reproduce

In an installation with some module that implements hook_user_format_name_alter implementation, like Real Name module โ†’ , edit any existing node. The account name is always used as the author name in the node status information, even for users with a different display name.

Proposed resolution

Replace the current call to AccountInterface::getAccountName() by AccountInterface::getDisplayName().

Remaining tasks

Review, tests.

User interface changes

As described in description.

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

๐Ÿ› Bug report
Status

Needs work

Version

10.1 โœจ

Component
Node systemย  โ†’

Last updated 1 day ago

No maintainer
Created by

๐Ÿ‡ช๐Ÿ‡ธSpain manuel.adan ๐ŸŒŒ

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.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    At this time we will need a D10 MR of the issue. Since the work has been in MRs lets try and keep them there. But from the changes I saw they look good. Still need to do a full test and code review.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Liam Morland โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    I have rebased the branch so that the existing commits are on top of 11.x. I think @Kristen Pol will need to edit the merge request so that it targets 11.x instead of 9.2.x.

  • Pipeline finished with Failed
    almost 2 years ago
    Total: 166s
    #43423
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States Kristen Pol Santa Cruz, CA, USA

    Sorry for the delay... version changed.

  • Pipeline finished with Success
    over 1 year ago
    Total: 816s
    #49738
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akhil Babu Chengannur
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Akhil Babu Chengannur
  • Pipeline finished with Success
    over 1 year ago
    Total: 498s
    #66358
  • Pipeline finished with Success
    8 months ago
    Total: 215s
    #378886
  • Pipeline finished with Failed
    7 months ago
    Total: 709s
    #390141
  • Pipeline finished with Failed
    7 months ago
    Total: 791s
    #390612
  • Pipeline finished with Success
    5 months ago
    Total: 724s
    #450706
  • Pipeline finished with Success
    5 months ago
    Total: 719s
    #451272
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    acbramley โ†’ changed the visibility of the branch 9.2.x to hidden.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    acbramley โ†’ changed the visibility of the branch 11.x to hidden.

  • Pipeline finished with Canceled
    5 months ago
    Total: 93s
    #457517
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley
  • Pipeline finished with Success
    4 months ago
    Total: 245954s
    #457518
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Seems like a simple change, IS is clear

    1) Drupal\Tests\node\Functional\NodeEditFormTest::testNodeAuthorDisplayName
    Behat\Mink\Exception\ExpectationException: The string "<em>3</em>" was not found anywhere in the HTML response of the current page.
    /builds/issue/drupal-3183509/vendor/behat/mink/src/WebAssert.php:888
    /builds/issue/drupal-3183509/vendor/behat/mink/src/WebAssert.php:363
    /builds/issue/drupal-3183509/core/tests/Drupal/Tests/WebAssert.php:559
    /builds/issue/drupal-3183509/core/modules/node/tests/src/Functional/NodeEditFormTest.php:320
    FAILURES!
    Tests: 4, Assertions: 105, Failures: 1.
    

    Shows the test coverage

    See no issue.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Instead of creating a new functional test for this one assertion, can the test be moved into the existing \Drupal\Tests\node\Functional\NodeEditFormTest::testNodeEdit method? I see @larowlan suggested reusing NodeEditFormTest which I think means a new method but testNodeEdit is for testing the functionality of that form. Leaving at RTBC.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Agreed with #34, saves a full Drupal install, moving to needs work for that.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    I'm not a fan of dumping a huge number of assertions into such a generic test case where it's not really clear what the intention of the test is.

    However, there is testNodeMetaInformation which seems fitting for this so I've moved it there.

  • Pipeline finished with Success
    3 months ago
    Total: 647s
    #483297
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley
  • Pipeline finished with Success
    3 months ago
    Total: 822s
    #491763
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia snehal-chibde

    I have tested the changes on Drupal 11.0.x.
    Following are the steps I have performed to test the same.

      • Installed the Real name module .
      • Added a field 'First name'
      • Under Real name tab, added [user:field_first_name]
    • I applied the latest MR and the value set for the field name added via Real name module is visible under the authoring information section on node edit page.
      Added screenshots for reference.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    Going to self RTBC this since it was only set back for merging the test changes which were fixed with https://git.drupalcode.org/project/drupal/-/merge_requests/352/diffs?com...

  • Pipeline finished with Success
    about 2 months ago
    Total: 2220s
    #529718
  • Issue was unassigned.
  • Status changed to RTBC about 1 month ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Great manual testing @Kristen Pol! And thanks @snehal-chibde for verifying it still works on Drupal 11.

    Crediting @smustgrave for issue management and verifying the test-only patch fails as expected.

    Saving credits.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    I do have an additional question. Does this change core's behavior, without any contrib module? Can someone do before-and-after screenshots of core alone? If so, it's actually kind of a non-trivial change. I might ask the usability team or the UX managers for their +1 on the change to core if so. (I might be over-sensitive to this since I hate when things try to force me to display my "real name" instead of my username!) ๐Ÿ˜…

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia acbramley

    Does this change core's behavior, without any contrib module?

    Not at all, this is the code of getDisplayName

        $name = $this->getAccountName() ?: \Drupal::config('user.settings')->get('anonymous');
        \Drupal::moduleHandler()->alter('user_format_name', $name, $this);
        return $name;
    

    There is no implementation of hook_user_format_name_alter in core, therefore it would be equivalent to getAccountName (what we're changing from). Unless we really care that the Anonymous user name is changing in this specific context.

    Reminder that this is just changing the Authoring Information part of the node edit form.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    OK great, thanks @acbramley for confirming!

    • xjm โ†’ committed f7ace406 on 11.x
      Issue #3183509 by acbramley, liam morland, sudiptadas19, kristen pol,...
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    I don't totally agree that this is a bug, BTW, and would almost call it a feature request, but let's split the difference at "task". Either way, it doesn't matter, because it's in! Committed to 11.x only as a user interface change. Thanks!

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

  • Production build 0.71.5 2024