Search by title is capped to 128 characters limit

Created on 12 March 2020, over 4 years ago
Updated 22 June 2023, about 1 year ago

Problem/Motivation

Original problem statement

When I perform a search from the admin content view anyway the search field limits the input to 128 characters. This makes no sense to me, but at least who compiles the search form is aware of what's going on.

I had to struggle with a rest service that was duplicating for no apparent reasons my contents because it couldn't find entities with titles >128 characters.

What actually happens is that if part of the title (<128 characters) is provided (e.g., ?title=...) results are found, otherwise if the complete title is passed through the query, an empty view is returned, while the content is obviously there.

A fix has been proposed in the past, see here โ†’ . Is there any reason about this design? What's your opinion?

Steps to reproduce

  1. Create a new standard Drupal instance with DrupalPod
  2. Once the site is ready, visit the home page
  3. Log into the website
  4. Go to the main content admin page
  5. In the title search field, input a long search string ("this is a really long search request that is supposed to go more than 128 characters as a test of an issue where text inputs are being limited by Drupal Views.")
  6. You will see the string cut off in the input field after 128 characters
  7. If you submit the search, inspect the url query parameter in the browser location field; you will see the search string truncated after 128 characters

Proposed resolution

Update the maxlength setting for string inputs to allow 256 characters instead of the default 128.

Remaining tasks

  1. Investigate whether new/updated tests are needed

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

Update view exposed filter string input field to accept up to 256 characters (up from the default 128 as set by the Textfield render element)

โœจ Feature request
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Viewsย  โ†’

Last updated 1 minute ago

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly artsakenos

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia amanshukla6158

    patch for 10.0.x

  • Patch #14 applied successfully on drupal 9.5 and drupal 10.0.x work fine and it looks good to me.
    Thank you

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Rinku Jacob 13 Kerala

    I have tested the patch #14 on drupal version 10.1.x. After applying the patch#14 maxlength attribute value changed to 255.
    But patch #2 maxlength attribute value is null. Why this changes happened in new patch. Which value is acceptable ?

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Questions and comments in #10 have not been addressed
    Issue summary update is still needed

    Patch #2 still applied to D10.1 so rerolls in #13 and #14 were not needed so removing credit.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    I think this core issue should be solved, we're running into this again and again in different situations and modules: ๐Ÿ“Œ Increase or remove default textfield #maxlength=128 Needs review

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States volkswagenchick San Francisco Bay Area

    Needs issue summary update
    See comment #10

    Tagging this for DrupalCon Pittsburgh 2023.

    Please save for a mentee at the mentored workshop at DrupalCon Pittsburgh 2023.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom ChrisDarke London

    Migrating Pittsburgh 2023 to Pittsburgh2023 tag for cleanup

  • Assigned to aaronpinero
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States aaronpinero
  • Issue was unassigned.
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States aaronpinero
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States aaronpinero

    Looking at this issue, it seems like the following specific tasks will help get it to RTBC:

    1. rewrite of the issue summary using the standard template. Also, generalizing the summary since this is about a search input but the character limit affects views generally.

    2. agreeing on the patch that sets maxlength to 255. This seems to be a responsible setting (as opposed to null) and matches the aforementioned title character limit.

    3. Check to see what tests are available for this module and if tests are adequate or need to be updated.

    These notes are mostly for #novice #contribution #DrupalConPittsburgh2023

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

    The parent issue has proposed a fix that would address this issue "further up the chain" from Views. However, that fix is against Drupal 11.x, so we do need a fix applied for Drupal 9.5 (as this will be around for a while yet). The parent issue also suggests (option b) to set the maxlength to to 256 instead of 128 and we should probably go with that, providing a fix against Drupal 9.5.x

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

    As suggested in #7 and #10, I have created an updated version of the patch that has comments.

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

    Existing tests for the StringFilter in the Views module all have to do with whether or not use of the exposed filter produces the expected result set. I don't know what sort of assertion one might use to to test this change other than adding a very simple test that checks to see if the input string longer than 128 characters is truncated. This is easy enough to test manually, so I don't know that it's necessary to add an automated test.

    If no one has a differing viewpoint, this could be RTBC.

  • Status changed to Needs review about 1 year ago
  • last update about 1 year ago
    Custom Commands Failed
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States aaronpinero

    Setting to needs review to get some other eyes on this.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Thank you for working on this!

    Changing the issue to 11.x as that's the current development branch. Fixes and changes will be merged there first and backported.

    #28 had a CC failure You can check for build errors by running ./core/scripts/dev/commit-code-check.sh locally.

    If this issue is resolved in another issue we should close this one out and move over credit.

  • Assigned to nitin_lama
  • Status changed to Needs review about 1 year ago
  • last update about 1 year ago
    30,341 pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    I think CC failure is because of cspell plugin in core. Somehow the term 'backported' is not present in the cspell dictionary.txt. Regenerating the cspell dictionary.txt will resolve the issue. Also before starting, ensure that JavaScript dev dependencies are up-to-date.

    cd core
    yarn install
    

    To regenerate cspell dictionary.txt you can use the following command in terminal:

    cd core
    yarn spellcheck:make-drupal-dict
    

    Not sure how to fix this in drupal issue queue via patch therefore providing patch with the regenerated dictionary.txt.

  • Issue was unassigned.
  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Not yet ready for review.

    There are still open tags that need to be addressed.

    And unless youโ€™re a maintainer shouldnโ€™t assign tickets to yourself. Leaving a comment is just fine

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Alright Providing patch for 11.x. Thanks.

  • last update about 1 year ago
    29,505 pass
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Lendude Amsterdam

    Nice to see this move!

    +++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
    @@ -277,6 +277,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    +        // This could be removed if #3331028 is resolved and backported.
    

    // @todo remove when https://www.drupal.org/project/drupal/issues/3331028 ๐Ÿ“Œ Increase or remove default textfield #maxlength=128 Needs review lands.

    That is what we tend to do as wording, not just mention the issue number. This also means we wouldn't need to expand the dictionary and that change can be removed.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nitin_lama

    Updated patch as per #36.

  • last update about 1 year ago
    29,507 pass, 1 fail
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands Lendude Amsterdam
    +++ b/core/modules/views/src/Plugin/views/filter/StringFilter.php
    @@ -277,6 +277,9 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
    +        // @todo remove when https://www.drupal.org/project/drupal/issues/3331028 lands.
    

    this is over 80 characters but doesn't bother the linting? ยฏ\_(ใƒ„)_/ยฏ

    Test failure seems unrelated

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Seems issue summary update and test coverage still missing

  • last update 6 months ago
    CI aborted
Production build 0.69.0 2024