Problem/Motivation

Currently usernames as links are trimmed when over 20, to 15 + 3 periods.

Proposed resolution

Trim when over 30, to 29 + an ellipsis character. Use a constant for trimming length as suggested in #93 and fix other mentioned issues.

Remaining tasks

#111 Do we need any theming (for mobile)?
#161 In #120, the $variables['trim_length'] was added. Verify that this works. Is there actually a way for a theme (such as the Seven theme) to set this variable? Answered in comment #226.

User interface changes

Longer usernames, see screenshots.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because there is no functional bug, only an update to existing functionality.
Issue priority Minor
Unfrozen changes Not Frozen because it changes markup and automated tests only.
Prioritized changes The main goal of this issue is usability. 

Additional Explanation

A whole lot of board posts, questions and articles out on the web are calling for usernames not getting truncated to 15 characters when displayed as links, for example in node view:
- https://drupal.org/node/82672
- https://drupal.org/node/80953
- https://drupal.org/node/85476
- https://drupal.org/node/810938
- http://drupal.stackexchange.com/questions/54054
- http://data.agaric.com/stop-drupal-from-shortening-long-usernames
- http://sscnet.ch/content/keep-drupal-truncating-user-names
- http://grokbase.com/p/drupal/support/07667d4acm/long-username-getting-tr...
- ...

While some limit might be necessary to avoid extremely (!) long usernames breaking the layout, 21 or 25 or even 30 characters are perfectly right and quite usual, especially if a full name or email address is provided.
We don't want to make configurable whatever can be overridden by code, but at least we want to provide a diligent default that makes overriding the exception rather than the regular case.
Therefore I'd propose to raise or waive the limit given in theme_preprocess_username().

Screenshots after applying patch in #91

Long Usernames MOBILE BEFORE

Long Usernames MOBILE AFTER

Long Usernames DESKTOP BEFORE

Long Usernames DESKTOP AFTER

CommentFileSizeAuthor
#250 2266991-after_patch.jpg40.97 KBgaurav-mathur
#250 2266991-before_patch.jpg37.42 KBgaurav-mathur
#246 2266991_216-246.patch1.58 KBmanojkumar_97
#241 MoreThan31.png32.69 KBasha nair
#240 afterPatch.png35.32 KBasha nair
#240 beforePatch.png33.38 KBasha nair
#239 after.png32.24 KBrakhi soni
#239 before.png30.24 KBrakhi soni
#239 Allow-longer-usernames-displayed-as-links-2266991-239.patch633 bytesrakhi soni
#237 after_patch.PNG50.49 KBdevashish jangid
#237 before_patch.PNG50.58 KBdevashish jangid
#234 afterpatchdesktop.png52.29 KBrinku jacob 13
#234 beforepatchdesktop.png43.49 KBrinku jacob 13
#234 afterpatchmobile.png54.85 KBrinku jacob 13
#234 beforepatchmobile.png55.72 KBrinku jacob 13
#230 after-patch.png37.2 KBbhumikavarshney
#221 before-patch.png24.18 KBsulfikar_s
#221 after-patch.png26.94 KBsulfikar_s
#220 Screenshot from 2021-03-31 14-43-25.png30.88 KBvikashsoni
#218 interdiff-218.txt1.08 KBkapilv
#216 2266991-216.patch7.19 KBkuldeep_mehra27
#214 interdiff_212-214.txt1.8 KBravi.shankar
#214 2266991-214.patch7.1 KBravi.shankar
#212 2266991-212.patch7.2 KBkuldeep_mehra27
#210 2266991-210.patch7.2 KBkuldeep_mehra27
#208 2266991-208.patch7.23 KBkuldeep_mehra27
#205 2266991-205.patch7.1 KBajv009
#204 2266991-204.patch7.1 KBajv009
#203 2266991-203.patch7.13 KBajv009
#190 2266991-190-interdiff.txt3.51 KBlokapujya
#190 2266991-190.patch7.22 KBlokapujya
#188 after-mob.png123.67 KBamit.drupal
#187 after.png52.04 KBamit.drupal
#187 before.png53 KBamit.drupal
#185 allow_longer_usernames-2266991-185.patch7.34 KBjofitz
#185 interdiff-183-185.txt9.64 KBjofitz
#183 allow_longer_usernames-2266991-183.patch7.16 KBjofitz
#164 after.png52.19 KBnesta_
#164 before.png53.44 KBnesta_
#164 allow_longer_usernames-2266991-164.patch7.19 KBnesta_
#164 interdiff-2266991-149-164.txt621 bytesnesta_
#159 truncating_username.png145.43 KBhugronaphor
#149 2266991-149-interdiff.txt1.21 KBlokapujya
#149 2266991-149.patch6.58 KBlokapujya
#148 2266991-148-interdiff.txt2.57 KBlokapujya
#148 2266991-148.patch6.58 KBlokapujya
#144 2266991-134-144-interdiff.txt5.9 KBlokapujya
#144 2266991-144.patch6.58 KBlokapujya
#138 interdiff-2266991-125-138.txt7.06 KBth_tushar
#138 user-Allow-longer-usernames-displayed-as-links-2266991-138.patch9.73 KBth_tushar
#135 user-Allow-longer-usernames-displayed-as-links-2266991-135.patch9.81 KBth_tushar
#134 2266991-133-interdiff.txt4.81 KBlokapujya
#134 2266991-133.patch6.73 KBlokapujya
#132 2266991-129-interdiff.txt4.18 KBlokapujya
#129 user-Allow-longer-usernames-displayed-as-links-2266991-129.patch6.86 KBth_tushar
#125 interdiff-2266991-120-123.txt54.28 KBmohit_aghera
#125 allow_long_username-2266991-123.patch6.81 KBmohit_aghera
#120 interdiff.patch1.44 KBsivaji_ganesh_jojodae
#120 allow_long_username-2266991-120.patch6.76 KBsivaji_ganesh_jojodae
#115 allow_longer_usernames-2266991-115.patch6.15 KBkostyashupenko
#111 admin_people_mobile_after.png46.73 KBxjm
#111 admin_people_mobile_before.png49.61 KBxjm
#109 allow_longer_usernames-2266991-109.patch5.98 KBdimaro
#109 interdiff-2266991-107-109.txt1.79 KBdimaro
#107 interdiff-allow_longer_usernames-2266991-102-107.txt2.61 KBkeopx
#107 allow_longer_usernames-2266991-107.patch5.98 KBkeopx
#103 interdiff-allow_longer_usernames-2266991-100-102.txt393 byteskeopx
#103 allow_longer_usernames-2266991-102.patch5.99 KBkeopx
#100 interdiff-allow_longer_usernames-2266991-91-100.txt4.47 KBkeopx
#100 allow_longer_usernames-2266991-100.patch6.01 KBkeopx
#94 long-usernames-mobile-before.png18.47 KBrteijeiro
#94 long-usernames-mobile-after.png20.92 KBrteijeiro
#94 long-usernames-desktop-before.png17.79 KBrteijeiro
#94 long-usernames-desktop-after.png20.28 KBrteijeiro
#92 long-username-before.png17.88 KBrteijeiro
#92 long-username-after.png19.6 KBrteijeiro
#91 allow_longer_usernames-2266991-91.patch5.52 KBzaporylie
#91 interdiff-88-91.txt1.26 KBzaporylie
#88 interdiff.txt704 bytesrteijeiro
#88 allow_longer_usernames-2266991-88.patch5.48 KBrteijeiro
#86 interdiff-allow_longer_usernames-2266991-68-86.txt3.79 KBsumitmadan
#86 allow_longer_usernames-2266991-86.patch5.48 KBsumitmadan
#79 interdiff-allow_longer_usernames-2266991-68-78.txt4.64 KBkeopx
#79 allow_longer_usernames-2266991-78.patch5.48 KBkeopx
#77 allow_longer_usernames-2266991-77.patch4.81 KBkeopx
#77 interdiff-allow_longer_usernames-2266991-68-77.txt4.14 KBkeopx
#77 allow_longer_usernames-2266991-77.patch4.81 KBkeopx
#68 allow_longer_usernames-2266991-68.patch5.44 KBsumitmadan
#68 interdiff.txt1.05 KBsumitmadan
#60 user-show_longer_authornames-2266991-60.patch5.37 KBkeopx
#60 interdiff-user-show_longer_authornames-2266991-48-60.txt270 byteskeopx
#54 capt6.png59.46 KBkeopx
#54 capt5.png42.73 KBkeopx
#54 capt4.png99.37 KBkeopx
#54 capt3.png47.26 KBkeopx
#54 capt2.png54.59 KBkeopx
#54 capt1.png52.54 KBkeopx
#51 capt7.png47.13 KBkeopx
#51 capt6.png49.81 KBkeopx
#51 capt5.png48.34 KBkeopx
#51 capt4.png55.21 KBkeopx
#51 capt3.png55.75 KBkeopx
#51 capt2.png49.83 KBkeopx
#51 capt1.png51.61 KBkeopx
#48 interdiff-user-show_longer_authornames-2266991-41-48.txt529 byteskeopx
#48 user-show_longer_authornames-2266991-48.patch5.4 KBkeopx
#41 interdiff-2266991-37-41.txt1.32 KBkeopx
#41 user-show_longer_authornames-2266991-41.patch5.4 KBkeopx
#37 user-show_longer_authornames-2266991-37.patch5.37 KBlegolasbo
#37 interdiff-33-37.txt5.16 KBlegolasbo
#33 user-show_longer_authornames-2266991-33.patch5.13 KBthijsvdanker
#31 interdiff-28-31.txt3.59 KBlegolasbo
#31 2266991-31.patch4.64 KBlegolasbo
#28 interdiff-2266991-23-26.txt3.62 KBpgautam
#28 2266991-28.patch4.89 KBpgautam
#26 2266991-26.patch4.01 KBpgautam
#25 interdiff.txt539 bytesstar-szr
#23 2266991-23.patch4.89 KBsharique
#19 2266991-19.patch4.89 KBlokapujya
#18 2266991-18.patch4.89 KBlokapujya
#14 interdiff-10-14.txt948 bytesmartin107
#14 longer_username.2266991-14.patch4.88 KBmartin107
#10 longer_username.2266991-10.patch4.62 KBducktape
#7 longer_username.2266991-7.patch4.21 KBducktape
#1 longer_username.2266991-1.patch667 bytespancho

Issue fork drupal-2266991

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pancho’s picture

Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new667 bytes

Attached patch raises the limit to 30 characters and uses an ellipsis instead of three periods.

dawehner’s picture

I guess we need some basic testcoverage to know that truncating works as expected. Btw. you could directly replace it with Unicode::strlen() already.

dman’s picture

Issue tags: +Needs tests, +Novice
pwolanin’s picture

Status: Needs review » Needs work
oskar_calvo’s picture

I have tested the patch from #1, and it seems to works fine in nodes author, and in "Who's new" blocks, and it works fine.

dman’s picture

@oskar_calvo : "Needs tests" is not just looking for "Works OK for me today".

It is "We need automated unit tests added to core code that prove that this change performs as needed, and can be reliably re-tested automatically for every single change that happens in the future"

That's the difference between "Needs (automated) Tests" and "Needs (some) Testing/verification". The difference between these two type of testing is sort of a big deal.

It would be cool if you got involved with coding tests to the point where you could *prove* the fix works, and not just offer anecdotal support. It's a big step, I know.

Confirming that "It works for me" is also really helpful input and does help move things forward, so thanks for that! - it counts, and encourages folk who want to do unit-testing that this is worthwhile.

ducktape’s picture

Status: Needs work » Needs review
StatusFileSize
new4.21 KB

I have added some tests for the username. Node author, comment author and the "who's new" block gets checked if the full username is present or not.

wim leers’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

Thanks!

I've got mostly nitpicks, but I think there's also a subtle flaw in the current solution — an additional precise test for the expected truncated username would've picked that up, so it might be worthwhile adding an assertion like $this->assertText('<my really long user name cut off to 29 characters>…').

  1. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,118 @@
    + * Definition of Drupal\user\Tests\UserUsernameTest.
    

    s/Definition of Drupal/Contains \Drupal/

  2. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,118 @@
    +  /**
    +   * The profile to install as a basis for testing.
    +   *
    +   * Using the standard profile to test username functionality.
    +   *
    +   * @var string
    +   */
    +  protected $profile = 'standard';
    

    Is it necessary to use the standard profile? It's preferable to not use that, because it's significantly slower than the testing profile.

  3. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,118 @@
    +      'description' => 'Tests username functionality e.g. truncating.',
    

    Missing comma after "functionality".

  4. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,118 @@
    +   * Tests author name display on nodes.
    ...
    +   * Tests author name on comments.
    

    Let's use consistent descriptions here.

  5. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,118 @@
    +  }
    +}
    

    Missing newline — we always ensure there is one newline before and after a method.

  6. +++ b/core/modules/user/user.module
    @@ -639,8 +639,8 @@ function template_preprocess_username(&$variables) {
    +  if (drupal_strlen($name) > 30) {
    +    $name = drupal_substr($name, 0, 27) . '…';
    

    This uses the ellipsis character (…) rather than three periods (...) — great! :)

    But… doesn't that mean the substring of the 29 first characters should be taken, rather that of the first 27 characters?

The last submitted patch, 7: longer_username.2266991-7.patch, failed testing.

ducktape’s picture

Status: Needs work » Needs review
StatusFileSize
new4.62 KB

Good point there, Wim. I changed the truncating logic to "29 plus the ellipsis". I also fixed the remarks in the test and switched to the testing profile. It's a lot faster now indeed, thanks!

Status: Needs review » Needs work

The last submitted patch, 10: longer_username.2266991-10.patch, failed testing.

gnuget’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Needs work

#10: could you provide an interdiff next time? :)

Just a few more nitpicks, then I'll be able to RTBC this:

  1. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,127 @@
    +  protected $userShortName;
    ...
    +  protected $userLongName;
    

    Missing docblocks.

  2. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,127 @@
    +  public static function getInfo() {
    ...
    +  public function setUp() {
    

    {@inheritdoc}

martin107’s picture

Status: Needs work » Needs review
StatusFileSize
new4.88 KB
new948 bytes

Fixed issues from #13.. hope this helps

joshua.boltz’s picture

Status: Needs review » Reviewed & tested by the community

#14 patch seems to have fixed the issue with the character cut-off change to 29+ellipsis of the user name.
I've verified it working on node list view and node view.

gnuget’s picture

I did a quick review of this patch and i just find one coding standard nitpick:

+++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
@@ -0,0 +1,143 @@
+  public static $modules = array(
+    'node',
+    'block',
+    'comment_test',
+    'user_test_views'
+  );

The last element of this array needs a comma at the end.

For everything else, looks good to me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
git ac https://drupal.org/files/issues/longer_username.2266991-14.patch
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  4996  100  4996    0     0  17034      0 --:--:-- --:--:-- --:--:-- 22204
error: patch failed: core/modules/user/user.module:639
error: core/modules/user/user.module: patch does not apply

Needs a reroll

lokapujya’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new4.89 KB

Reroll. Note the switch from drupal_substr to Unicode::truncate().

lokapujya’s picture

StatusFileSize
new4.89 KB

Added the missing comma.

rick hood’s picture

Verified output for node author seems to be 28 characters +ellipsis

<span rel="schema:author">
Submitted by <span class="field field-node--uid field-name-uid field-type-entity-reference field-label-hidden" data-quickedit-field-id="node/1/uid/en/full"><a title="View user profile." href="/user/1" lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="" content="s6f7a89244c0c857s6f7a89244c0c857s6f7a89244c0c857s6f7a89244c0" class="username">s6f7a89244c0c857s6f7a89244c0…</a>
</span>

Also 28 characters +ellipsis on comment form and who's new.

keopx’s picture

Status: Needs review » Reviewed & tested by the community

Result

<span class="field field-node--uid field-name-uid field-type-entity-reference field-label-hidden" data-quickedit-field-id="node/2/uid/es/full"><span lang="" about="/user/4" typeof="schema:Person" property="schema:name" datatype="" content="no012345678901234567890123456789si">no01234567890123456789012345…</span></span>

catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
@@ -0,0 +1,143 @@
+   * The user with the longer short username.

longer short username?

sharique’s picture

Status: Needs work » Needs review
StatusFileSize
new4.89 KB

Updated patch.

star-szr’s picture

Status: Needs review » Needs work

Thank you @Sharique, here's the missing interdiff.

  1. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,143 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public static function getInfo() {
    +    return array(
    +      'name' => 'Username functionality',
    +      'description' => 'Tests username functionality, e.g. truncating.',
    +      'group' => 'User',
    +    );
    +  }
    

    getInfo() is gone, please see https://www.drupal.org/node/2301125.

  2. +++ b/core/modules/user/lib/Drupal/user/Tests/UserUsernameTest.php
    @@ -0,0 +1,143 @@
    +    $this->assertText($this->userShortName->getUsername(), 'Untruncated username is found');
    ...
    +    $this->assertNoText($this->userLongName->getUsername(), 'Untruncated username is not found');
    +    $this->assertText(drupal_substr($this->userLongName->getUsername(), 0, 29) . '…', 'Truncated username is found');
    ...
    +    $this->assertText($this->userShortName->getUsername(), 'Untruncated username is found');
    ...
    +    $this->assertNoText($this->userLongName->getUsername(), 'Untruncated username is not found');
    +    $this->assertText(drupal_substr($this->userLongName->getUsername(), 0, 29) . '…', 'Truncated username is found');
    ...
    +    $this->assertText($this->userShortName->getUsername(), 'Untruncated username is found');
    +    $this->assertNoText($this->userLongName->getUsername(), 'Untruncated username is not found');
    +    $this->assertText(drupal_substr($this->userLongName->getUsername(), 0, 29) . '…', 'Truncated username is found');
    

    Assertion messages usually are complete sentences (add a period to the end). I would also suggest that removing the word "is" from all these might be an improvement.

star-szr’s picture

StatusFileSize
new539 bytes

Forgot the attachment.

pgautam’s picture

Status: Needs work » Needs review
StatusFileSize
new4.01 KB

Incorporated #24 in this patch. Please review this patch.

star-szr’s picture

@pgautam - interdiff please!

pgautam’s picture

StatusFileSize
new4.89 KB
new3.62 KB

@Cottser, sorry for that. here is updated patch with interdiff file.

star-szr’s picture

No need to apologize @pgautam just to good to get in the habit :) I cancelled testing on the first patch.

At a glance the changes look good. Thank you!

The last submitted patch, 26: 2266991-26.patch, failed testing.

legolasbo’s picture

Issue tags: +Amsterdam2014
StatusFileSize
new4.64 KB
new3.59 KB

I've reviewed the patch(es) and found that #26 and #28 were both missing changes. I've created a new patch combining #26 and #28.

thijsvdanker’s picture

Assigned: Unassigned » thijsvdanker
Status: Needs review » Needs work

The UserUsernameTest.php file is placed in the core/modules/user/lib/Drupal/user/Tests directory, but should be in the core/modules/user/src/Tests directory.

I'm working on a reroll.

thijsvdanker’s picture

Assigned: thijsvdanker » Unassigned
Status: Needs work » Needs review
StatusFileSize
new5.13 KB

Rerolled with the test in core/modules/user/src/Tests.

esod’s picture

Status: Needs review » Reviewed & tested by the community

The patch applies cleanly and the use case works. It's good for me to know that UserUsernameTest.php should be in core/modules/user/src/Tests although others should confirm.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 33: user-show_longer_authornames-2266991-33.patch, failed testing.

legolasbo’s picture

I'll have a look at the failing test

legolasbo’s picture

Status: Needs work » Needs review
StatusFileSize
new5.16 KB
new5.37 KB

The tests failed because they had several errors which I've fixed and tested thoroughly.

mradcliffe’s picture

+++ b/core/modules/user/src/Tests/UserUsernameTest.php
@@ -0,0 +1,146 @@
+    $this->container->get('comment.manager')->addDefaultField('node', 'article');

Is this standard practice to depend on the container in tests? Can we make the node commentable in another way?

If this is the only method of creating fields quickly in tests, then OK.

mradcliffe’s picture

It looks like core does this a lot in tests.

Maybe add some screen shots and update the issue summary.

keopx’s picture

Assigned: Unassigned » keopx
Issue tags: -Amsterdam2014

Working in this issue.

Need reroll

keopx’s picture

Assigned: keopx » Unassigned
StatusFileSize
new5.4 KB
new1.32 KB

Re-roll

Status: Needs review » Needs work

The last submitted patch, 41: user-show_longer_authornames-2266991-41.patch, failed testing.

The last submitted patch, 37: user-show_longer_authornames-2266991-37.patch, failed testing.

The last submitted patch, 41: user-show_longer_authornames-2266991-41.patch, failed testing.

mradcliffe’s picture

Here's some failing tests to look at locally to debug why they're crashing. There are more fails than those listed in the review log section, but these aren't making it through their entire test. Most of those tests are in Comment and Search modules. Try running a test like CommentTitleTest locally.

+++ b/core/modules/user/user.module
@@ -528,8 +528,8 @@ function template_preprocess_username(&$variables) {
+  if (drupal_strlen($name) > 30) {

Unicode::strlen() should still be used here, not drupal_strlen().

keopx’s picture

Status: Needs work » Needs review
StatusFileSize
new5.4 KB
new529 bytes

reroll.

Thanks @mradcliffe for review :)

diego21’s picture

Status: Needs review » Reviewed & tested by the community

It works for me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs screenshots

I would have expected some screenshots of the admin/people screen and other pages with user names displayed, eg. comments, nodes and user pages.

keopx’s picture

Status: Needs work » Needs review
StatusFileSize
new51.61 KB
new49.83 KB
new55.75 KB
new55.21 KB
new48.34 KB
new49.81 KB
new47.13 KB

Hi, thanks for review.

Here screenshot. I think with this is correct.

Info:

  • node -->1
  • comment -->1
  • user "admin" -->1
  • user "test user 0123456789 012345 looks well user name test" -->5
diego21’s picture

Status: Needs review » Reviewed & tested by the community

Good stuff, thanks @keopx

diego21’s picture

Status: Reviewed & tested by the community » Needs work

Sorry, I think there is something wrong with that screeshots

keopx’s picture

Status: Needs work » Needs review
StatusFileSize
new52.54 KB
new54.59 KB
new47.26 KB
new99.37 KB
new42.73 KB
new59.46 KB

Here correct screenshot, sorry with confusion :-$

Sorry @diego21

diego21’s picture

Status: Needs review » Reviewed & tested by the community

It's ok @keopx, changed state to RTBC

Thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

This issue is a normal task so we need to outline how it fits within the allowable Drupal 8 beta criteria. Can someone add Drupal 8 beta phase evaluation template to the issue summary.

Also the title needs fixing because we are not displaying the full username.

lokapujya’s picture

Title: Display full username on links » Allow longer usernames displayed as links.
Issue tags: -Needs issue summary update, -Needs screenshots

.

lokapujya’s picture

Issue summary: View changes
+++ b/core/modules/user/src/Tests/UserUsernameTest.php
@@ -0,0 +1,146 @@
\ No newline at end of file

Needs a newline at end of file.

lokapujya’s picture

Category: Task » Feature request
Priority: Normal » Minor
Issue summary: View changes
keopx’s picture

Status: Needs work » Needs review
StatusFileSize
new270 bytes
new5.37 KB

correct mistake

lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 60: user-show_longer_authornames-2266991-60.patch, failed testing.

mradcliffe’s picture

Issue summary: View changes
lokapujya’s picture

sumitmadan’s picture

StatusFileSize
new1.05 KB
new5.44 KB

Rerolled the patch with test failure fixes. Hope this will work. :)

sumitmadan’s picture

Status: Needs work » Needs review
sharique’s picture

Status: Needs review » Needs work
+++ b/core/modules/user/src/Tests/UserUsernameTest.php
@@ -18,6 +19,8 @@
+  use CommentTestTrait;

It is added already, so no need to add it again.

sumitmadan’s picture

Status: Needs work » Needs review

Drupal is using php's trait strategy. Check out #2134513: [policy, no patch] Trait strategy.

We need to add use Trait to make it working. Working without this cause test to fail.

sharique’s picture

Status: Needs review » Needs work
+++ b/core/modules/user/src/Tests/UserUsernameTest.php
@@ -0,0 +1,149 @@
+use Drupal\comment\Tests\CommentTestTrait;
...
+  use CommentTestTrait;

I mean CommentTestTrait is used in "Use" statement is used twice. Please remove second one.

sharique’s picture

Status: Needs work » Needs review

Oh, so this is how traits works.

lokapujya’s picture

Issue summary: View changes
+++ b/core/modules/user/src/Tests/UserUsernameTest.php
@@ -50,8 +53,8 @@ class UserUsernameTest extends WebTestBase {
+    $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));

Optional: Should we go with the shorthand array syntax? Here and other places in the patch.

Also, I have unfrozen this issue.

keopx’s picture

Status: Needs review » Reviewed & tested by the community

@lokapujya I do not understand your comment, I see other test and use this same line.

Works fine for me.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 68: allow_longer_usernames-2266991-68.patch, failed testing.

keopx’s picture

Here reroll with changed method .

Old: String::checkPlain
New: SafeMarkup::checkPlain

Changed to support new reserved php class names.

sumitmadan’s picture

Status: Needs work » Needs review
keopx’s picture

Here reroll with changed method .

Old: String::checkPlain
New: SafeMarkup::checkPlain

Changed to support new reserved php class names.

PS: sorry, because I forget some lines

The last submitted patch, 77: allow_longer_usernames-2266991-77.patch, failed testing.

The last submitted patch, 77: allow_longer_usernames-2266991-77.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 79: allow_longer_usernames-2266991-78.patch, failed testing.

keopx’s picture

I do not but in local enviroment test works :-/

The last submitted patch, 79: allow_longer_usernames-2266991-78.patch, failed testing.

sumitmadan’s picture

Status: Needs work » Needs review
StatusFileSize
new5.48 KB
new3.79 KB

#79 Patch worked fine for me but seems patch was failing because of interdiff.

Changed patch and interdiff according to #68. Lets give it a try.

Status: Needs review » Needs work

The last submitted patch, 86: allow_longer_usernames-2266991-86.patch, failed testing.

rteijeiro’s picture

Status: Needs work » Needs review
StatusFileSize
new5.48 KB
new704 bytes

Fixed a missing period. I can confirm that tests pass in local so let's see what's wrong with testbot.

Status: Needs review » Needs work

The last submitted patch, 88: allow_longer_usernames-2266991-88.patch, failed testing.

zaporylie’s picture

Assigned: Unassigned » zaporylie

I just tried to test it on my local machine and it returns fails (just like testbot):

Fail      Other      UserUsernameTest.  145 Drupal\user\Tests\UserUsernameTest-
    Untruncated username found.
Pass      Other      UserUsernameTest.  146 Drupal\user\Tests\UserUsernameTest-
    Untruncated username not found.
Fail      Other      UserUsernameTest.  147 Drupal\user\Tests\UserUsernameTest-
    Truncated username found.

I will look at it.

zaporylie’s picture

Assigned: zaporylie » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.26 KB
new5.52 KB

Let's try it again, this time without block cache.

rteijeiro’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new19.6 KB
new17.88 KB

If it's green, then it's RTBC for me.

Long Username BEFORE

Long Username AFTER

xjm’s picture

Category: Feature request » Task
Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs manual testing +Needs issue summary update

Thanks for the beta evaluation, test coverage, manual testing, and screenshots! I'd consider this a task -- it is altering an existing bit of functionality, not adding a new one. I think it makes sense to increase this default length as 15 is so short as to be a bit unfriendly. I've had to override this on sites before.

  1. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -0,0 +1,149 @@
    +      $this->randomString(30)
    ...
    +      $this->randomString(31)
    ...
    +    $this->assertText(SafeMarkup::checkPlain(Unicode::truncate($this->userLongName->getUsername(), 29, FALSE, TRUE)), 'Truncated username found.');
    ...
    +      'comment_body[0][value]' => $this->randomMachineName(20),
    ...
    +      'comment_body[0][value]' => $this->randomMachineName(20),
    ...
    +    $this->assertText(SafeMarkup::checkPlain(Unicode::truncate($this->userLongName->getUsername(), 29, FALSE, TRUE)), 'Truncated username found.');
    

    So even if we choose not to make this default truncation length a constant or configurable, can we at least add a comment in the test that explains where this magic integer is set? (That is, the preprocess implementation.)

  2. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -0,0 +1,149 @@
    +    $this->assertText(SafeMarkup::checkPlain($this->userShortName->getUsername()), 'Untruncated username found.');
    +    $this->assertNoText(SafeMarkup::checkPlain($this->userLongName->getUsername()), 'Untruncated username not found.');
    

    These assertion texts are very confusing. "Untruncated username found" is asserted immedidately after "untruncated username not found"! In the code it's clear that it's two different names.

    I think it'd actually be better to remove the assertion message texts from all the similar assertions in this new test class. assertText() has a default assertion message that provides more helpful and specific information for debugging than this. In this case the assertion texts are hiding information.

  3. +++ b/core/modules/user/user.module
    @@ -459,8 +459,8 @@ function template_preprocess_username(&$variables) {
    -  if (Unicode::strlen($name) > 20) {
    -    $name = Unicode::truncate($name, 15, FALSE, TRUE);
    +  if (Unicode::strlen($name) > 30) {
    +    $name = Unicode::truncate($name, 29, FALSE, TRUE);
    

    I considered whether this should be a constant or something configurable rather than a magic integer, but since this is a preprocess anyway and can be overridden as desired, that's probably not necessary. The comment above this hunk also documents that it's the specific preprocess's responsibility to truncate safely to the desired length.

    However, the 30 and 29 do seem a bit arbitrary. Would it be clearer to have a variable for the length, and truncate to length - 1?

    Also, I think the previous 15 vs. 20 was to leave room for the characters of the ellipsis. So now a 31-character username will have its length increased to 32. No? Let's at least document the lengths chosen.

My only other concern is that this might be very wide in existing tables where the user name is a high priority field, for example the user admin view. Can we get additional screenshots of long, truncated usernames in that view, both at a desktop width and a mobile width? Embed the screenshots as @rteijeiro has or (even better!) in the issue summary. (Also the summary looks a bit out of date.)

Thanks!

rteijeiro’s picture

rteijeiro’s picture

keopx’s picture

Assigned: Unassigned » keopx
rteijeiro’s picture

Issue summary: View changes
rteijeiro’s picture

Issue summary: View changes
rteijeiro’s picture

Issue summary: View changes
keopx’s picture

Assigned: keopx » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.01 KB
new4.47 KB

Thanks

Kudos for @xjm and @rteijeiro

rteijeiro’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/user/user.module
    @@ -45,6 +45,16 @@
    + *
    + */
    ...
    +
    +/**
    

    This change looks wrong.

  2. +++ b/core/modules/user/user.module
    @@ -45,6 +45,16 @@
    + *
    

    Please, document the constant. For example: Trimming length for long usernames.

The last submitted patch, 100: allow_longer_usernames-2266991-100.patch, failed testing.

keopx’s picture

Status: Needs work » Needs review
StatusFileSize
new5.99 KB
new393 bytes

Status: Needs review » Needs work

The last submitted patch, 103: allow_longer_usernames-2266991-102.patch, failed testing.

lokapujya’s picture

Shouldn't USERNAME_TRIMM_LENGTH be with just one M?

lokapujya’s picture

USERNAME_TRIMM_LENGTH-1 is to include the ellipsis character (which used to be 3 periods.

keopx’s picture

Status: Needs work » Needs review
StatusFileSize
new5.98 KB
new2.61 KB
dimaro’s picture

Assigned: Unassigned » dimaro
Status: Needs review » Needs work
dimaro’s picture

Assigned: dimaro » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.79 KB
new5.98 KB

Update comments.

keopx’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

xjm’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs review
StatusFileSize
new49.61 KB
new46.73 KB

Thanks @rteijeiro for the awesome screenshots :D But the reason I specified the user admin view is this:

So based on the fact that we're breaking an existing UI a little with this change, I think this needs more discussion.

I also discussed the class constant with @amateescu and @dawehner. Rather than adding a global constant, they suggested adding as a variable in user_theme(). Then I think it would be easier for themes to override it and still get the proper truncation, but that also gives us a place to document the quantity.

keopx’s picture

Issue summary: View changes
joelpittet’s picture

Version: 8.0.x-dev » 8.1.x-dev

Moving to get this tackled in 8.1.x version since we are in RC.

lokapujya’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

needs a reroll + see #111 (about moving the constant to a variable in user_theme().

kostyashupenko’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new6.15 KB

Patch from #109 re-rolled

Status: Needs review » Needs work

The last submitted patch, 115: allow_longer_usernames-2266991-115.patch, failed testing.

xjm’s picture

Issue tags: -Novice

Looks like the novice tag was added back in 2014, when core was in a different state. Since there isn't a clear novice task on this issue per https://www.drupal.org/core-mentoring/novice-tasks, I am removing the novice tag.

lokapujya’s picture

First 2 test fails: user_format_name_alter() doesn't get called anymore because the of this change:

+++ b/core/modules/user/user.module
@@ -470,10 +475,9 @@ function template_preprocess_username(&$variables) {
-  $name  = $account->getDisplayName();
...
+  $name = $variables['name_raw'] = $account->getUsername();

getDisplayName invokes the hooks, but getUserName does not.

The test is relying on the alter hook to run and change the name to an ID.

lokapujya’s picture

Issue tags: +Needs reroll

So, we aren't really done with the reroll.

sivaji_ganesh_jojodae’s picture

Status: Needs work » Needs review
StatusFileSize
new6.76 KB
new1.44 KB

Patch re-rolled and used variables to allow themer to overriding.

Status: Needs review » Needs work

The last submitted patch, 120: interdiff.patch, failed testing.

The last submitted patch, 120: allow_long_username-2266991-120.patch, failed testing.

th_tushar’s picture

Assigned: Unassigned » th_tushar
Issue tags: +drupalconasia2016
dman’s picture

These tests have been failing is what seems to be an unrelated area

exception: [Uncaught exception] Line 98 of core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php:
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for block.block.zjxrwbkj with the following errors: block.block.zjxrwbkj:settings.cache missing schema in Drupal\Core\Config\Testing\ConfigSchemaChecker->onConfigSave() (line 98 of /var/www/html/core/lib/Drupal/Core/Config/Testing/ConfigSchemaChecker.php). Drupal\Core\Config\Testing\ConfigSchemaChecker->onConfigSave(Object, 'config.save', Object) (Line: 116)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('config.save', Object) (Line: 232)

This has been happening on our local dev environments, and Now I am seeing it in the testbot report too.

I can't see what the connection is between "ConfigSchemaChecker" and what we are testing here.

mohit_aghera’s picture

Status: Needs work » Needs review
StatusFileSize
new6.81 KB
new54.28 KB

Changing string validation in patch based on testbot output.

mohit_aghera’s picture

Something is wrong with interdiff. @th_tushar please work as mentioned by @dman

Status: Needs review » Needs work

The last submitted patch, 125: allow_long_username-2266991-123.patch, failed testing.

dimaro’s picture

@sivaji@knackforge.com
You can create an interdiff correctly following the steps in this url:
https://www.drupal.org/documentation/git/interdiff

I hope you find it useful.

th_tushar’s picture

Assigned: th_tushar » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.86 KB

Hey,

The issue will be fixed with the updated patch. Changing the status of the issue to "Needs Review".

Thanks,
th_tushar

Status: Needs review » Needs work
lokapujya’s picture

Could you please add an interdiff?

lokapujya’s picture

StatusFileSize
new4.18 KB
th_tushar’s picture

Status: Needs work » Needs review

Hey,

Reviewed the interdiff file in #132, its fine. Its solves the issues with the submitted patch in #129.

Changing the issue status to "Need Review".

Thanks,

lokapujya’s picture

Issue tags: -Needs reroll
StatusFileSize
new6.73 KB
new4.81 KB

Reverse the change made in the reroll described in #118.
Remove some changes that seem unnecessary.

th_tushar’s picture

The new patch that fixes all the issues.

lokapujya’s picture

@th_tushar the interdiff in #132 IS the interdiff between #125 and #129. It shows the changes that you made. You should provide an interdiff with each patch that you upload so that we can see the changes between patches.

gnuget’s picture

Status: Needs review » Needs work
+++ b/core/modules/user/src/Tests/UserUsernameTest.php
@@ -0,0 +1,164 @@
+
+use Drupal\Core\Url;
+//use Drupal\views\Entity\View;
+use Drupal\views\Views;
+use Drupal\views\Tests\ViewTestBase;
+//use Drupal\Core\Template\Attribute;
+use Drupal\Component\Utility\SafeMarkup;
+use Drupal\Component\Utility\Unicode;

Is there a reason why are we commenting these lines instead of deleting them?

And Yes, we need a new interdiff for every new patch.

th_tushar’s picture

Status: Needs work » Needs review
StatusFileSize
new9.73 KB
new7.06 KB

Hi All,

I have removed the commented code and added the interdiff.txt file in comparison to patch added in #125. The attached patch fixes all the issue.

Thanks,
th_tushar

harshil.maradiya’s picture

Yes, patch is working as expected

kshama_deshmukh’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed the patch and its working as expected.

lokapujya’s picture

Status: Reviewed & tested by the community » Needs review
  1. +++ b/core/modules/comment/src/Tests/CommentPreviewTest.php
    @@ -50,13 +50,13 @@ function testCommentPreview() {
    -    $this->assertEscaped('<em>' . $this->webUser->id() . '</em>');
    +    $this->assertNoEscaped('<em>' . $this->webUser->id() . '</em>');
    ...
    -    $this->assertRaw('<em>' . $this->webUser->id() . '</em>');
    +    $this->assertNoRaw('<em>' . $this->webUser->id() . '</em>');
    
    +++ b/core/modules/tracker/src/Tests/TrackerTest.php
    @@ -216,13 +216,13 @@ function testTrackerUser() {
    -    $this->assertEscaped('<em>' . $this->user->id() . '</em>');
    +    $this->assertNoEscaped('<em>' . $this->user->id() . '</em>');
    ...
    -    $this->assertRaw('<em>' . $this->user->id() . '</em>');
    +    $this->assertNoRaw('<em>' . $this->user->id() . '</em>');
    

    We should not be changing these tests.

  2. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -7,17 +7,19 @@
    +use Drupal\Core\Url;
    +use Drupal\views\Views;
    +use Drupal\views\Tests\ViewTestBase;
    ...
    -use Drupal\simpletest\WebTestBase;
    ...
    -class UserUsernameTest extends WebTestBase {
    +class UserUsernameTest extends ViewTestBase {
    

    Why is this being changed to a viewstest?

  3. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -65,7 +67,7 @@ public function setUp() {
    -      $this->randomString(30)
    +      $this->randomMachineName(25)
    
    @@ -77,8 +79,10 @@ public function setUp() {
    -      $this->randomString(31)
    +      $this->randomMachineName(35)
    

    why changing the string sizes? Why using machine name (it's a user name not a machine name)?

  4. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -100,8 +104,8 @@ public function testTruncatedNodeAuthorName() {
    -    $this->assertTrue(SafeMarkup::isSafe($this->userShortName->getUsername()), 'Username is marked safe');
    ...
    +    $this->assertTrue($this->userShortName->getUsername(), 'Username is marked safe');
    

    Why removing the isSafe() if the assert text says "marked safe"?

I have fixed all these issues in the #134 patch.

gnuget’s picture

Status: Needs review » Needs work

#141 looks great!
Thanks!

Just one very small nitpick.

+++ b/core/modules/user/src/Tests/UserUsernameTest.php
@@ -0,0 +1,158 @@
+    $this->assertNoText(SafeMarkup::checkPlain($this->userLongName->getUsername()));
+    $this->assertText(SafeMarkup::checkPlain(Unicode::truncate($this->userLongName->getUsername(), USERNAME_TRIM_LENGTH - 1, FALSE, TRUE)));
+  }
+
+
+  /**
+   * Tests username display in Who's New block.
+   */

Let's remove one empty line here.

Also, all the new patches to I've reviewed lately use the new short array syntax in new functions and methods, can we use that syntax here as well?

lokapujya’s picture

Assigned: Unassigned » lokapujya
lokapujya’s picture

Status: Needs work » Needs review
StatusFileSize
new6.58 KB
new5.9 KB

also removed some deprecated safemarkup calls.

gnuget’s picture

Status: Needs review » Needs work

Some final nits:

  1. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -0,0 +1,158 @@
    +    // Tests if the username is trimmed to USERNAME_TRIM_LENGTH value.
    +    // @see template_preprocess_username().
    +    $this->assertTrue(Html::escape($this->userLongName->getUsername()));
    ...
    +    $this->drupalPostForm('comment/reply/node/' . $node->id() . '/comment', $comment, t('Save'));
    +    $this->assertTrue(Html::escape($this->userLongName->getUsername()));
    +    $this->drupalLogin($this->userLongName);
    

    Those assertTrue are repeated, even if they are in different methods the $this->userLongName is defined in the setup, so I think we can remove one.

  2. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -0,0 +1,158 @@
    +
    +    $this->drupalLogin($this->userShortName);
    +    $comment =[
    +      'subject[0][value]' => $this->randomMachineName(),
    

    There is a missing space after the "=" operator in the array.

  3. +++ b/core/modules/user/src/Tests/UserUsernameTest.php
    @@ -0,0 +1,158 @@
    +    // @see template_preprocess_username().
    

    I think the @see statements no need the period in the end.

Can we update the description of the issue? I think the "remaining task" is outdated.

This looks great! Thanks!

lokapujya’s picture

Assigned: lokapujya » Unassigned

1.) Looks like those assertTrue()'s should be assertText()s.

lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

Status: Needs work » Needs review
StatusFileSize
new6.58 KB
new2.57 KB

The assertTexts might fail.

lokapujya’s picture

StatusFileSize
new6.58 KB
new1.21 KB

The last submitted patch, 148: 2266991-148.patch, failed testing.

gnuget’s picture

Status: Needs review » Reviewed & tested by the community

Great work!

droplet’s picture

Shouldn't it be more smarter to trim username without SPACE only ?

lokapujya’s picture

@droplet: can you elaborate on #152? I don't completely get it. Are you suggesting we trim whitespace after trimming the length?

We can't ignore #111 either. The theme may need an update to keep edit buttons visible on mobile?

gnuget’s picture

@droplet I'm not sure if that would be smarter, even if the username has an space it could be something like:

"this isasuperlongusernamewithanspace"

Even with an space this username would need to be trimmed.

lokapujya’s picture

But what if the space is the last character after trimming? That could be a separate issue though (if that's what he meant.)
"this ..." vs.
"this..."

lokapujya’s picture

Issue summary: View changes
droplet’s picture

@gnuget,

ahh, you right :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 149: 2266991-149.patch, failed testing.

hugronaphor’s picture

StatusFileSize
new145.43 KB

The case of "this ..." will not happen because Unicode::PREG_CLASS_WORD_BOUNDARY is used while detecting the stripped string.
@see: https://github.com/drupal/drupal/blame/8.1.x/core/lib/Drupal/Component/U...

gnuget’s picture

Status: Needs work » Needs review

This is good to know!

Thanks!

It seems to the testbot fail for an unknown reason, I will test it again just to be sure if something is wrong.

lokapujya’s picture

So, the remaining task is to make the operation links visible in mobile, see comment #111. How do we do this?

+++ b/core/modules/user/user.module
@@ -469,14 +469,18 @@ function template_preprocess_username(&$variables) {
+  if (!isset($variables['trim_length'])) {
+    $variables['trim_length'] = USERNAME_TRIM_LENGTH;
+  }

In #120, the $variables['trim_length'] was added. Is there actually a way for a theme (such as the Seven theme) to set this variable?

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lokapujya’s picture

nesta_’s picture

Issue tags: +DrupalCampES
StatusFileSize
new621 bytes
new7.19 KB
new53.44 KB
new52.19 KB

Try to fix the remaining task on #161, where says that we have to look on #111.

Before:
before

After:
after

keopx’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 164: allow_longer_usernames-2266991-164.patch, failed testing.

gnuget’s picture

+++ b/core/themes/seven/css/components/form.css
@@ -290,6 +290,14 @@ select {
+  form[action="/admin/people"] table {
+    table-layout: fixed;
+  }
+  form[action="/admin/people"] table td.views-field-name {
+    white-space: nowrap;
+    overflow: hidden;
+    text-overflow: ellipsis;
+  }

I looked at the code if there are other places where the CSS is just for a specific form action and I haven't found anything.

So maybe this is not a good approach to fixing this?

nesta_’s picture

why not @gnuget?

This only happens in this case, you will never change the route and is the best solution that can be given from the visuals no other functionality of other modules and pages undergo this modification.

lokapujya’s picture

A more common way might be to target the ID of the form (for one off CSS)?

lokapujya’s picture

why not @gnuget?

The action is not guaranteed to be the same. For example, would it change in another language? What if an alias is used? etc..

gnuget’s picture

why not @gnuget?

According to our guidelines:

Common CSS Pitfalls #

To better understand the best practices provided below, it can be helpful to review some common approaches that impede our goals of predictability, maintainability, reusability and scalability.

Pitfall: Modifying components based on context #

/* Modifying a component when it’s in a sidebar. */
.sidebar .component {}
This may seem natural, but actually makes CSS less predictable and maintainable. Sooner or later you’re going to need that component style somewhere other than a sidebar! Or, the reverse may happen: a new developer places a component in the sidebar and gets an unexpectedly different appearance.

Pitfall: Relying on HTML structure #

Mirroring a markup structure in our CSS selectors makes the resulting styles easy to break (with markup changes) and hard to reuse (because it’s tied to very specific HTML).

So, I think we are here modifying a component based in context AND relying on HTML structure, so yes definitely this is not the correct approach.

You can read more about this here: https://www.drupal.org/coding-standards/css/architecture

nesta_’s picture

Thank you @gnuget & @lokapujya. What is the next step you want me to do?

Remove "action" attribute in css file?

lokapujya’s picture

@nesta_ You can implement how ever you think is best and we will review. I think the CSS needs a class or a form ID selector.

What happens when NOT in mobile view. A new patch should maybe have a screenshot of both mobile and non mobile. I would have to know more about Bartik to give you a better answer. It possibly needs a media query (if it's not already in one, can't tell from the patch)?

Separately, we still have to answer the 2nd question in #161.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

dimaro’s picture

Add test against 8.3.x on #164.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nesta_’s picture

Assigned: Unassigned » nesta_
Issue tags: +DevDaysSeville
lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

Issue summary: View changes

Updating Remaining tasks.

lokapujya’s picture

Issue summary: View changes

Need to answer #161. maybe have a test for it, because i'm not sure it works or remove it.

dimaro’s picture

Issue tags: +Needs reroll

The latest patch no longer applies.
Tagging this issue.

jofitz’s picture

Assigned: nesta_ » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new7.16 KB

Re-rolled.

gnuget’s picture

Issue summary: View changes
Status: Needs review » Needs work

Accord with this, any new test must use the new base classes (BrowserTestBase) and here we are still using WebTestBase.

It is necessary to migrate it.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new9.64 KB
new7.34 KB

Good spot, @gnuget! BlindReRoll-- :)

  • Based the test class on BrowserTestBase.
  • Moved the file to the correct location.
  • Corrected the namespace.
  • Updated deprecated functions.

Status: Needs review » Needs work

The last submitted patch, 185: allow_longer_usernames-2266991-185.patch, failed testing.

amit.drupal’s picture

StatusFileSize
new53 KB
new52.04 KB

Test patch #164 on drupal 8.4.x-dev. and its working fine.

amit.drupal’s picture

StatusFileSize
new123.67 KB

Sorry, I Forgot Mobile Attachment.

gnuget’s picture

Hi amit.drupal

Thanks for your manual tests.

But before to continue testing this we need to make sure that all the tests are passing, on #185 there are 2 failing tests, also we still need to answer #161 also per #167 this needs a different approach.

Thanks!

lokapujya’s picture

Status: Needs work » Needs review
StatusFileSize
new7.22 KB
new3.51 KB

Fix the failing tests.

lokapujya’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Needs Tests for the change in #120. Or, steps to do a manual test of #120 might be helpful.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lokapujya’s picture

Issue summary: View changes
Issue tags: -DrupalCampES, -DevDaysSeville
lokapujya’s picture

Issue summary: View changes

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

bohus ulrych’s picture

Hi, this looks promising. Would it be possible to create patch for recent Drupal 8/9 versions?
Thanks

ajv009’s picture

Assigned: Unassigned » ajv009
ajv009’s picture

Status: Needs work » Needs review
StatusFileSize
new7.13 KB

Porting to 9.2.x

ajv009’s picture

StatusFileSize
new7.1 KB
ajv009’s picture

StatusFileSize
new7.1 KB

Status: Needs review » Needs work

The last submitted patch, 205: 2266991-205.patch, failed testing. View results

kuldeep_mehra27’s picture

Assigned: ajv009 » kuldeep_mehra27
kuldeep_mehra27’s picture

Assigned: kuldeep_mehra27 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new7.23 KB
kuldeep_mehra27’s picture

Assigned: Unassigned » kuldeep_mehra27
kuldeep_mehra27’s picture

Assigned: kuldeep_mehra27 » Unassigned
StatusFileSize
new7.2 KB

Status: Needs review » Needs work

The last submitted patch, 210: 2266991-210.patch, failed testing. View results

kuldeep_mehra27’s picture

Status: Needs work » Needs review
StatusFileSize
new7.2 KB

Status: Needs review » Needs work

The last submitted patch, 212: 2266991-212.patch, failed testing. View results

ravi.shankar’s picture

StatusFileSize
new7.1 KB
new1.8 KB

Fixed failed tests of patch #212.

lokapujya’s picture

  1. +++ b/core/modules/user/tests/src/Functional/UserUserNameTest.php
    @@ -0,0 +1,156 @@
    +      $this->randomString(30)
    ...
    +      $this->randomString(31)
    

    We are getting usernames that are creating invalid email addresses. I changed to randomMachineName() and it passed.

  2. +++ b/core/modules/user/tests/src/Functional/UserUserNameTest.php
    @@ -0,0 +1,156 @@
    +    $this->drupalLogin($this->userShortName);
    ...
    +    $this->drupalLogin($this->userLongName);
    

    Previously, the content showed up on the homepage and this worked. Might get around this by calling $this->drupalGet('node/1'); after login (or we could set the content to show up on front page for this test.)

  3. +++ b/core/modules/user/tests/src/Functional/UserUserNameTest.php
    @@ -0,0 +1,156 @@
    +    $this->assertSession()->pageTextContains(Unicode::truncate($this->userLongName->getAccountName(), USERNAME_TRIM_LENGTH - 1, FALSE, FALSE));
    

    USERNAME_TRIM_LENGTH - 3 should pass. Something changed. The username is a link. Maybe the single character … got replaced with ... and it got trimmed a couple characters?

kuldeep_mehra27’s picture

StatusFileSize
new7.19 KB
ravi.shankar’s picture

@kuldeep_mehra27 can you please add interdiff as well.

kapilv’s picture

StatusFileSize
new1.08 KB
kapilv’s picture

Status: Needs work » Needs review
vikashsoni’s picture

StatusFileSize
new30.88 KB

There is no issue like text lapping when username is length above 25 and 30 sharing screenshot ...

sulfikar_s’s picture

Status: Needs review » Needs work
StatusFileSize
new26.94 KB
new24.18 KB

I've applied the patch and I think it needs work. Though the screen doesn't get flows off the mobile screen, the 'edit' button overlaps the 'roles' for small screen devices.

I'm attaching the screenshots below.

Before,
before-patch

After,
after-patch

Changing back to Needs Work!

bohus ulrych’s picture

Hi,
patch can by now applied without any problem. But I don't know where and how to overwrite default 30 characters length value.
Thanks

lokapujya’s picture

Admin theme can trim it to the current length.

See change in comment #120. Maybe, we want to trim it to current length in user_theme so that it works the way it does now. Then other themes can use the full length?

bohus ulrych’s picture

Thanks @lokapujya but this is exactly where I need help.
I should be able to overwrite default value using $variables['trim_length'], but where?
In my admin theme (subtheme of seven) I was trying to change in in template_preprocess_username(). Function was triggered, $variables['trim_length'] was set, but it didn't worked.
Or do it using user_theme()? How, where - in the theme?
Thanks

lokapujya’s picture

If you are calling theme_user(), you can pass the variable. But, I don't see anyplace that actually calls theme('user', [variables]) to point us to an example. Maybe, the theme could implement username.html.twig and could use the untruncated name_raw and then the theme can truncate it however it wants to? Hopefully, someone that knows theming really well can explain better.

bohus ulrych’s picture

Thanks for help. Finally it is working.
1) apply patch
2) custom function themename_theme() in the themename.theme file

function themename_theme() {
    return [
        'username' => [
            'variables' => ['trim_length' => 50],
        ],
    ];
}

3) file templates/username.html.twig must exist

Then it seems to be working as expected. Don't know if this approach is best way - doesn't sound too much intuitive. But it is working, good starting point.

My 2 cents: const USERNAME_TRIM_LENGTH and Unicode::truncate($name, $variables['trim_length'] - 1, FALSE, TRUE) should follow current default Drupal's behavior, not to overwrite it with something else. IMHO this will cause troubles to all lot of people.

lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

Issue summary: View changes
bhumikavarshney’s picture

Status: Needs work » Needs review
StatusFileSize
new37.2 KB

Patch #216 works fine for me and no overlap issue is there.
Thanks

Poojita0802’s picture

Assigned: Unassigned » Poojita0802
Poojita0802’s picture

Assigned: Poojita0802 » Unassigned

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rinku jacob 13’s picture

StatusFileSize
new55.72 KB
new54.85 KB
new43.49 KB
new52.29 KB

Verified and tested patch#216 for drupal 9.3.x-dev version. Patch applied successfully and looks good to me.Adding screenshot for the reference.

bohus ulrych’s picture

FYI patch#216 successfully applied with Drupal 9.2.8 and seems to be working well.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

devashish jangid’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new50.58 KB
new50.49 KB

#216 Patch is working fine and shared the screenshot for the reference.

quietone’s picture

Version: 9.4.x-dev » 10.0.x-dev
Status: Reviewed & tested by the community » Needs work
Issue tags: -Needs tests +Needs issue summary update

Thanks to everyone for moving this along.

The issue summary needs to be updated. The screenshots in the IS are from the patch in #91. Instead they should always be from the latest patch. Having an up to date Issue summary helps the reviewer. Adding tag for an IS update.

The Issue Summary shows a remaining task that is not done. If it has been done, it needs to be indicated in the issue summary as well.

The last patch here is from 12 months ago and I see no code review of that patch since then. Setting to NW for a code review. There is a test in the patch, so removing tag.

I notice there is a change for the seven them. Does this need to be applied to other themes as well?

@Devashish Jangid, There are several steps, or core gate that an issue must pass first before it can be RTBC. Some of that is in my comments above. Also, screenshots for the patch were added in #234 and the patch has not been changed. Adding unnecessary screenshots does not help move an issue forward. Therefor, credit has been removed per How is credit granted for Drupal core issues.

rakhi soni’s picture

Version: 10.0.x-dev » 9.5.x-dev
Status: Needs work » Needs review
StatusFileSize
new633 bytes
new30.24 KB
new32.24 KB

I have created a patch to fix the issue of "Allow longer usernames displayed as links" for version 9.5x ,, kindly review patch.

asha nair’s picture

StatusFileSize
new33.38 KB
new35.32 KB

Applied #239 patch in 9.5.x-dev. Works fine for below 31 characters. Username is shown as some symbol when has more than 31 characters

asha nair’s picture

StatusFileSize
new32.69 KB
bohus ulrych’s picture

Hi all, this very simple patch #239 doesn't make sense to me.

It only increases limit for truncating from 20 to 30 characters.
If there are more than 30, then strange logic is applied:
$name = Unicode::truncate($name, 0, 27) . '…';
It seems like some garbage there.
And truncate function expects different arguments
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Component%21Util...

Patch #216 seems to be better option. Still works - tested with 9.4.7

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

@Rakhi Soni thank you for the patch for #239 but appears to be missing bulk of the changes from the patch before. Is there a reason to move all those changes and tests?

#216 does appear to be the more complete solution. Which will need to be rerolled for 10.1.
Also may have to be updated for the other themes as mentioned in #238 by @quietone as seven is removed in core.

Also still needs issue summary udpate.

Please try to address the issues before rerolling.

quietone’s picture

Status: Needs review » Needs work

Yes, look at the tags and see what need to be done. Often, updating the patch is not what is needed to get an issue reviewed. In this case, an up to date issue summary is needed. A review needs to see accurate information in the Issue Summary before they look at the code. See Write an issue summary for an existing issue for guidance.

manojkumar_97’s picture

Status: Needs work » Needs review
StatusFileSize
new1.58 KB

I have created a patch on Drupal 10.1.x agains #216. pls verify ...

gaurav-mathur’s picture

Assigned: Unassigned » gaurav-mathur

hi, i'll review it :)

Status: Needs review » Needs work

The last submitted patch, 246: 2266991_216-246.patch, failed testing. View results

gaurav-mathur’s picture

Assigned: gaurav-mathur » Unassigned
Status: Needs work » Needs review

Verified and tested patch#246 on Drupal 10.1.x Patch applied successfully.
Php Version:- 8.2
MySQL Version:- 8

Adding screenshot for the reference.
Thank You

gaurav-mathur’s picture

StatusFileSize
new37.42 KB
new40.97 KB
smustgrave’s picture

Status: Needs review » Needs work

Thank you for the interest and the testing but please read the tags and comments also. This was tagged for issue summary update in #238

That’s what will be needed to move this ticket forward.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.