Problem/Motivation

Site slogan is limited to 128 chars because \Drupal\Core\Render\Element\Textfield sets this as default

The workaround is https://www.drupal.org/forum/support/theme-development/2011-01-04/increa... since Drupal6

Proposed resolution

Increase length of slogan to 255

Remaining tasks

Create patch, add tests & commit

User interface changes

Before (128 characters allowed)
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer non justo quis ligula varius cursus quis quis neque. Nunc orci."

After (255 characters allowed)
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sed orci commodo, congue ipsum eu, finibus dolor. Sed molestie leo nec luctus mattis. Nulla id ex ac nunc sollicitudin vehicula nec eget odio. Vivamus lacus neque, varius ut magna vel viverra."

API changes

no

Data model changes

no

CommentFileSizeAuthor
#54 Screenshot 2020-07-13 at 9.54.04 PM.png124.75 KBsamiullah
#54 Screenshot 2020-07-13 at 9.49.31 PM.png122.68 KBsamiullah
#52 2928960-52.patch645 bytesKrzysztof Domański
#47 2928960-47.patch2.3 KBKrzysztof Domański
#47 interdiff-44-47.txt1.45 KBKrzysztof Domański
#44 2928960-44.patch2.36 KBDeepak Goyal
#44 diff_42-44.txt930 bytesDeepak Goyal
#42 2928960-42.patch2.48 KBDeepak Goyal
#42 diff_39-42.txt896 bytesDeepak Goyal
#39 diff_36-39.txt1.45 KBDeepak Goyal
#39 2928960-39.patch2.36 KBDeepak Goyal
#36 2928960-36.patch2.36 KBKrzysztof Domański
#36 interdiff-35-36.txt2.58 KBKrzysztof Domański
#35 diff_28-35.txt1.72 KBDeepak Goyal
#35 2928960-35.patch1.48 KBDeepak Goyal
#28 Increase-site-slogan-maxlength-2928960-28.patch2.69 KBNeslee Canil Pinto
#26 Increase-site-slogan-maxlength-2928960-26.patch2.69 KBNeslee Canil Pinto
#25 Increase-site-slogan-maxlength-2928960-25.patch2.69 KBNeslee Canil Pinto
#23 Increase-site-slogan-maxlength-2928960-23.patch1.51 KBNeslee Canil Pinto
#21 Increase-site-slogan-maxlength-2928960-21.patch639 bytesNeslee Canil Pinto
#9 2928960-9.patch1.42 KBwaspper
#4 2928960-4.patch1.38 KBandypost
#4 2928960-test-only.patch765 bytesandypost
#3 2928960-3.patch645 bytesandypost
#2 2928960-2.patch645 bytesandypost
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
FileSize
645 bytes

Simple patch

andypost’s picture

FileSize
645 bytes
andypost’s picture

Here's a test, tests still using simpletest so conversion will be done in #2862508: Convert system functional tests to phpunit

The last submitted patch, 4: 2928960-test-only.patch, failed testing. View results

The last submitted patch, 2: 2928960-2.patch, failed testing. View results

dawehner’s picture

+++ b/core/modules/system/src/Tests/System/PageTitleTest.php
@@ -142,4 +142,12 @@ public function testRoutingTitle() {
 
+  /**
+   * Tests that the site slogan has the correct maxlength.
+   */
+  public function testSloganSize() {
+    $this->drupalGet('admin/config/system/site-information');
+    $this->assertPattern('/<input .* id="edit-site-slogan" .* maxlength="255" .* \/>/', 'Site slogan field has correct maxlength in site settings form.');
+  }
+

Wouldn't be the better test whether you can actually enter 255 characters and save it?

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.

waspper’s picture

Attached proposed patch in #4 + changes for #7.

Cheers.

Status: Needs review » Needs work

The last submitted patch, 9: 2928960-9.patch, failed testing. View results

andypost’s picture

Status: Needs work » Needs review

requeued, failures in 8.6 looks unrelated

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @waspper!

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/system/src/Form/SiteInformationForm.php
--- a/core/modules/system/src/Tests/System/PageTitleTest.php
+++ b/core/modules/system/src/Tests/System/PageTitleTest.php

+++ b/core/modules/system/src/Tests/System/PageTitleTest.php
+++ b/core/modules/system/src/Tests/System/PageTitleTest.php
@@ -142,4 +142,16 @@ public function testRoutingTitle() {

Are we sure we want to add this to PageTitleTest?

This test isn't about page titles. The rest of the test looks unrelated to our issue here.

borisson_’s picture

testTitleXSS in that same class is about the same title. I don't see a better place to do this in.
We could create a followup for this issue to create a new test for that method + the new test added here.

dawehner’s picture

It would be easy to create a new test class, wouldn't it?

andypost’s picture

On other hand title and slogan coupled in page title generation, so I see no reason to refactor tests when pate title affected of front page at least

borisson_’s picture

It would be easy to create a new test class, wouldn't it?

I agree, that's easy, but I don't think we want to move testTitleXSS to that new test at the same time in this issue as well, that sounds like scope creep. I think that's better suited to a new (novice) followup.

borisson_’s picture

@larowlan: do you have an opinion about #17?

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.

idebr’s picture

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

The patch no longer applies since the affected test class was moved in #2862508: Convert system functional tests to phpunit

Neslee Canil Pinto’s picture

Status: Needs work » Needs review
FileSize
639 bytes

Slogan Text increased to 255 Characters

cilefen’s picture

Status: Needs review » Needs work

Thanks for helping out. We actually need the test changes so I’m setting this to “needs work”.

Neslee Canil Pinto’s picture

Status: Needs work » Needs review
FileSize
1.51 KB

Slogan Text increased to 255 Characters and added test

andypost’s picture

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

The added test needs formatting according to coding standards, NW for that https://www.drupal.org/pift-ci-job/1200769

Neslee Canil Pinto’s picture

Status: Needs work » Needs review
FileSize
2.69 KB

Slogan Text increased to 255 Characters and added test

Neslee Canil Pinto’s picture

Status: Needs review » Needs work

The last submitted patch, 26: Increase-site-slogan-maxlength-2928960-26.patch, failed testing. View results

Neslee Canil Pinto’s picture

Fixed Coding Standards Issues

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.

Neslee Canil Pinto’s picture

This patch needs a review

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.

quietone’s picture

Status: Needs review » Needs work

@Neslee Canil Pinto, thanks for the patch.

I reviewed the patch and found a few things. If you are like me the out of scope changes creep in when I accidentally reformat the code for the entire file and not the block I have changed.

  1. +++ b/core/modules/system/tests/src/Functional/System/PageTitleTest.php
    @@ -34,7 +34,13 @@ protected function setUp() {
    -    $this->contentUser = $this->drupalCreateUser(['create page content', 'access content', 'administer themes', 'administer site configuration', 'link to any page']);
    +    $this->contentUser = $this->drupalCreateUser([
    +      'create page content',
    +      'access content',
    +      'administer themes',
    +      'administer site configuration',
    +      'link to any page',
    +    ]);
    
    @@ -61,7 +67,7 @@ public function testTitleTags() {
    -  public function testTitleXSS() {
    +  public function testTitleXss() {
    
    @@ -106,7 +112,7 @@ public function testRoutingTitle() {
    -    // Test forms
    +    // Test forms.
    

    I've been pinged lately on out of scope changes so since there are not related to issue let's remove them. And we get a smaller easier to read patch.

  2. +++ b/core/modules/system/tests/src/Functional/System/PageTitleTest.php
    @@ -155,4 +161,17 @@ public function testRoutingTitle() {
    +      'site_slogan'  => $this->randomMachineName(255),
    

    Looks like an extra space before '=>'.

And the testbot reports a coding standards error.

Deepak Goyal’s picture

Assigned: Unassigned » Deepak Goyal
Deepak Goyal’s picture

Assigned: Deepak Goyal » Unassigned
Status: Needs work » Needs review
FileSize
1.48 KB
1.72 KB

Hi @quietone
Updated patch as you suggested please review.

Krzysztof Domański’s picture

1. I added test coverage of \Drupal\system\Form\SiteInformationForm.

2. I added a negative test.

+    $placeholders = [
+      '%maxlength' => $slogan_maxlength,
+      '%out_of_size' => $slogan_maxlength + 1,
+    ];
+    $this->assertSession()->responseContains(t('Slogan cannot be longer than %maxlength characters but is currently %out_of_size characters long.', $placeholders));

3. +1 for Increase length of slogan to 255. It looks enough. If someone needs more, they can still alter the form.

128 characters
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer non justo quis ligula varius cursus quis quis neque. Nunc orci.

255 characters
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sed orci commodo, congue ipsum eu, finibus dolor. Sed molestie leo nec luctus mattis. Nulla id ex ac nunc sollicitudin vehicula nec eget odio. Vivamus lacus neque, varius ut magna vel viverra.

longwave’s picture

+++ b/core/modules/system/tests/src/Functional/System/SiteInformationFormTest.php
@@ -0,0 +1,49 @@
+    $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
...
+    $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
...
+    $this->assertSession()->responseContains(t('Slogan cannot be longer than %maxlength characters but is currently %out_of_size characters long.', $placeholders));

We don't need to call t() in tests, we have ongoing issues elsewhere to remove these calls.

Deepak Goyal’s picture

Assigned: Unassigned » Deepak Goyal
Deepak Goyal’s picture

Hi @longwave
Made changes as you suggested please review.

Status: Needs review » Needs work

The last submitted patch, 39: 2928960-39.patch, failed testing. View results

Krzysztof Domański’s picture

@Deepak Goyal thanks for working on it!

The second output will be
Slogan cannot be longer than <em class="placeholder">255</em> characters but is currently <em class="placeholder">256</em> characters long.
We need to add html tags and we need the sprintf() function that formats the string.

$expected_error = sprintf('Slogan cannot be longer than <em class="placeholder">%d</em> characters but is currently <em class="placeholder">%d</em> characters long.', $slogan_maxlength, $slogan_maxlength + 1);
$this->assertSession()->responseContains($expected_error);
Deepak Goyal’s picture

Assigned: Deepak Goyal » Unassigned
Status: Needs work » Needs review
FileSize
896 bytes
2.48 KB

Hi @Krzysztof Domański
Made changes as you suggested please review.

Krzysztof Domański’s picture

Status: Needs review » Needs work

We no longer need the following code.

+    $placeholders = [
+      '%maxlength' => $slogan_maxlength,
+      '%out_of_size' => $slogan_maxlength + 1,
+    ];
Deepak Goyal’s picture

Hi @Krzysztof Domański
Removed above code please review.

Deepak Goyal’s picture

Status: Needs work » Needs review
longwave’s picture

+++ b/core/modules/system/tests/src/Functional/System/SiteInformationFormTest.php
@@ -0,0 +1,46 @@
+    $expected_error = sprintf('Slogan cannot be longer than <em class="placeholder">%d</em> characters but is currently <em class="placeholder">%d</em> characters long.', $slogan_maxlength, $slogan_maxlength + 1);
+    $this->assertSession()->responseContains($expected_error);

Instead of checking the explicit HTML output here should we use pageTextContains()?

Krzysztof Domański’s picture

andypost’s picture

Status: Needs review » Reviewed & tested by the community

It look good, not sure we need constant here

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 47: 2928960-47.patch, failed testing. View results

Krzysztof Domański’s picture

Status: Needs work » Reviewed & tested by the community

Unrelated random test failure. Back to RTBC.

catch’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/system/tests/src/Functional/System/SiteInformationFormTest.php
@@ -0,0 +1,46 @@
+
+  /**
+   * Tests that the site slogan has the correct maxlength.
+   */
+  public function testSloganSize() {
+    $slogan_maxlength = 255;
+
+    $edit = [
+      'site_slogan' => $this->randomMachineName($slogan_maxlength),
+    ];
+    $this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration');
+    $this->assertSession()->pageTextContains('The configuration options have been saved.');
+
+    $edit = [
+      'site_slogan' => $this->randomMachineName($slogan_maxlength + 1),
+    ];
+    $this->drupalPostForm('admin/config/system/site-information', $edit, 'Save configuration');
+    $expected_error = sprintf('Slogan cannot be longer than %d characters but is currently %d characters long.', $slogan_maxlength, $slogan_maxlength + 1);
+    $this->assertSession()->pageTextContains($expected_error);
+  }
+

This is a case where I don't think we should add test coverage - our configuration forms are generic and have generic test coverage.

Krzysztof Domański’s picture

This is a case where I don't think we should add test coverage - our configuration forms are generic and have generic test coverage.

+1 for this approach. A similar situation in the past #2277281-50: Sometimes you want more than 128 chars of allowed file extensions.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Well, that certainly makes the patch simpler :)

samiullah’s picture

Before Applying the patch I was able to site slogan with max length = 128 characters
After applying patch slogan max length = 255 character
This looks good
Moving to RTBC

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 2115909 and pushed to 9.1.x. Thanks!

  • catch committed 9d4de9c on 9.1.x
    Issue #2928960 by Neslee Canil Pinto, Deepak Goyal, andypost, Krzysztof...

Status: Fixed » Closed (fixed)

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

m4TT3rs’s picture

Seems like the patch does not account for the translation of the slogan, when I want to translate the slogan in a different language it's still limited to 128 chars for the other language.

Krzysztof Domański’s picture