Closed (fixed)
Project:
Real Name
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Mar 2018 at 13:13 UTC
Updated:
31 Mar 2018 at 20:04 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
idebr commentedAttached patch remove the overwrite from realname_update().
Comment #4
vegantriathleteFurther arguments against updating the name column in the User entity:
Comment #5
vegantriathleteComment #6
vegantriathleteIt looks like D7 used its own table and added a separate field to the User entity.
Comment #7
vegantriathleteThis does look like an almost 1:1 port directly from D7. It still uses the .install and hook_schema, it still adds the extra field to the user entity, and it still uses views.inc to expose itself to Views. Additionally it performs almost all the same logic in the .module file. So, I would agree that it is needlessly including the
$account->setUsername($realname);inside of therealname_updatefunction.Comment #8
vegantriathleteNaturally this patch is failing the
testRealnameUsernameAlter()test because that is looking specifically to see that the name column has been overwritten, which is exactly what this patch is trying to prevent.Comment #9
vegantriathletesimplesamlphp_auth explicitly uses getAccountName so that it can avoid any issues with getDisplayName. So, to beat this point, this module should not be updating the name column. It should only be using hook_user_format_name_alter.
Comment #10
idebr commented@vegantriathlete The override for the username is not actually saved to the database, the override is only active until the end of the request.
I have added a title_callback for the user canonical page so it renders the displayName instead of the accountName.
Comment #11
idebr commentedComment #12
vegantriathlete@idebr: But we DO encounter a situation in which it ends up getting written to the database. The details aren't important. The point is that the module shouldn't be doing the setUsername. Thanks for your work on this patch!
Comment #13
hass commentedThat is not needed. There is a case to fix all the bugs in core, see #2629286: Use getDisplayName() for user names consistently. You could help moving this case to a final patch!
Comment #14
hass commentedWhat a waste of time to write this patch... Have you seen #2881939: Roadmap D8 final ?
Comment #15
idebr commentedI had a look at the related issue in Core. It only changes the displayed name but not the data model of the user object. This means this specific code in Realname has to be updated regardless.
I assume you are referring to the related Core issue that changes the display name of the user canonical page? The RealnameBasicTest currently asserts the account display name, but not actually change any logic regarding this page title. If this is to be fixed in Drupal core, then let's remove the assertion from Realname so this issue is not dependent on the fix in the related core issue.
Comment #16
hass commentedNo idea what you are changing there and why.
Comment #17
idebr commentedMy apologies if the issue summary is unclear.
Assume the following account:
- Username: barack_obama
- First name (field_first_name): Barack
- Last name (field_last_name): Obama
and a Realname pattern:
[user:field_first_name] [user:field_lastname]The realname codes causes the following output:
Since the Realname module is only supposed to change the $account->getDisplayName(), the expected output would be the same string "barack_obama" before and after saving.
I have added a test case to \Drupal\realname\Tests\RealnameBasicTest::testRealnameUsernameAlter() to showcase the failing behavior.
Comment #18
idebr commentedrealname_remove_account_name_overwrite-2951535-17.patch is formatted incorrectly. This patch is the correct one.
Comment #22
hass commentedOh... now I got it. That is true and the currently committed code is not correct than.
Comment #24
hass commented