Needs work
Project:
Drupal core
Version:
main
Component:
user.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
17 Jul 2016 at 09:00 UTC
Updated:
30 Jan 2023 at 23:33 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
hass commentedComment #3
hass commentedComment #4
strykaizerDrupal core truncates to 15 characters when username has more then 20 characters.
Lets keep the output for default settings when truncated the same as core does now to prevent possible tests (in contrib) from failing.
Comment #5
hass commentedHow should this happen? The code truncates only if longer than 20 chars like before. There is no change. If format_username() is propery used, nothing can go wrong. I only removed an outdated workaround (hardcoded 5 chars) that should not used as there is the truncate utf8 function that works properly compared to substr.
Comment #6
strykaizer@hass
While I do agree that your patch makes more sense than current core solution, it does involves a change though.
If i'm not mistaken, atm, when a username is 20+ characters long, core keeps only 15 characters (and 3 dots).
This patch brakes possible tests with usernames 20+ characters long since truncate_utf8 will change it to 17 characters (+ 3 dots)
Comment #7
hass commentedThis can only happen if someone does NOT use the Drupal API format_username(). In such a case - the module has a bug and need to be corrected, too. By this change, we find them...
Comment #8
tatarbjHi all,
after testing the patch it's true it truncates differently the username as before because of the previously hardcoded 15 character goes up to 17. In order to change nothing for backward compatibility i've modified the patch to not at max_length of 20, but 18 (see interdiff).
I think this will guarantee all tests from core (as before), but also from contribs and even site specific tests will remain green.
Otherwise the proposal is really nice, because currently we are not able to truncate username as we would like to!
Bests,
Balazs.
Comment #9
hass commentedThat is still a change as we only abrivated the username if longer than 20 letters. My patch was safer
Comment #10
dpiUsername is truncated in Drupal 8.
This is more of a feature than a bug.
Comment #14
izmeez commentedNot sure what the directions are for this issue but just incase anyone is interested attached is an interdiff for the 7.x patches in #1 and #8.
Comment #19
sourabhrawat commentedUse following code in your theme
function THEME_preprocess_username(&$vars) {
//putting back what drupal core messed with
$vars['username'] = check_plain($vars['name_raw']);
}
Comment #20
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.