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
- Create a new standard Drupal instance with DrupalPod
- Once the site is ready, visit the home page
- Log into the website
- Go to the main content admin page
- 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.")
- You will see the string cut off in the input field after 128 characters
- 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
- 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)
| Comment | File | Size | Author |
|---|---|---|---|
| #37 | interdiff-28-37.txt | 675 bytes | nitin_lama |
| #37 | 3119290-37.patch | 848 bytes | nitin_lama |
| #35 | 3119290-35.patch | 1.1 KB | nitin_lama |
| #33 | Screenshot from 2023-06-21 16-30-34.png | 46.45 KB | nitin_lama |
| #33 | interdiff-28-33.txt | 211 bytes | nitin_lama |
Issue fork drupal-3119290
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
Comment #2
lendudeDon't think it's design really, Drupal just defaults all text fields to 128 characters. But I wouldn't call this a bug either. (maybe the rest thing? didn't try to reproduce that, we would need clearer steps to reproduce for that)
This does what #1033982: Exposed filter for a string has a maximum of 128 characters did, except not for D6 :)
Do we require test coverage for this? Seems unneeded, but again, maybe for the rest thing if we can reproduce that?
Comment #7
jhedstromPerhaps a comment here noting the purpose of this. Unsure if a test is needed, but I suppose an existing test for this filter plugin could easily be updated to add a search that is more than 128 characters in length?
Comment #8
abhijith s commentedApplied patch #2 and it removes the
maxlengthattribute from title search.Before patch:

After patch:

RTBC +1
Comment #9
smustgrave commentedTest patch #2 after verifying the issue and confirmed the patch works.
Comment #10
quietone commentedA reminder that just because a patch works, an issue may not be eligible for RTBC.
The issue summary is not complete. Will someone add the standard template and complete the sections, see Write an issue summary for an existing issue for guidance. Adding tag, this is also suitable for a novice task.
Comment #7 has asked for a comment to be added to the patch, that has not happened.
This issue does not have tests. Both #2 and #7 question the need for tests and how to do it but #7 suggests that an existing test for this filter plugin could be used. The issue summary has steps using the UI, perhaps with steps to reproduce this could be manually tested, if an automated test is not possible. Testing needs to be investigated.
The screenshots in #8 and #9 show that the maxlength element is removed. I am not convinced that this is proving that the problem stated in the Issue Summary has indeed been fixed. I am removing credit for the screenshots in #9 because they are duplicates and the RTBC is a simple 'this patch works'.
This is a feature request, lets get a patch for 9.5 and 10.
Comment #13
reenaraghavan commentedComment #14
amanshukla6158 commentedpatch for 10.0.x
Comment #15
Sonam goswami52 commentedPatch #14 applied successfully on drupal 9.5 and drupal 10.0.x work fine and it looks good to me.
Thank you
Comment #16
rinku jacob 13 commentedI have tested the patch #14 on drupal version 10.1.0-dev. 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 ?
Comment #17
smustgrave commentedQuestions 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.
Comment #18
rinku jacob 13 commented@smustgrave, patch 13 has changed the max length attribute value, in patch #2 max length value is null. but for patch #13 it is 255. that is the difference. That's why I have asked in comment #16 which value is correct.
Comment #19
anybodyI think this core issue should be solved, we're running into this again and again in different situations and modules: #3331028: Increase default textfield #maxlength=128 to 256
Comment #20
volkswagenchickNeeds 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.
Comment #21
chrisdarke commentedMigrating Pittsburgh 2023 to Pittsburgh2023 tag for cleanup
Comment #22
aaronpinero commentedComment #23
aaronpinero commentedComment #24
aaronpinero commentedLooking 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
Comment #25
aaronpinero commentedThe 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
Comment #26
aaronpinero commentedComment #27
aaronpinero commentedComment #28
aaronpinero commentedAs suggested in #7 and #10, I have created an updated version of the patch that has comments.
Comment #29
aaronpinero commentedExisting 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.
Comment #30
aaronpinero commentedSetting to needs review to get some other eyes on this.
Comment #31
smustgrave commentedThank 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.shlocally.If this issue is resolved in another issue we should close this one out and move over credit.
Comment #32
nitin_lamaComment #33
nitin_lamaI 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.
To regenerate cspell dictionary.txt you can use the following command in terminal:
Not sure how to fix this in drupal issue queue via patch therefore providing patch with the regenerated dictionary.txt.
Comment #34
smustgrave commentedNot 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
Comment #35
nitin_lamaAlright, providing patch for 11.x. Thanks.
Comment #36
lendudeNice to see this move!
// @todo remove when https://www.drupal.org/project/drupal/issues/3331028 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.
Comment #37
nitin_lamaGot it. Updated patch as per #36.
Comment #38
lendudethis is over 80 characters but doesn't bother the linting? ¯\_(ツ)_/¯
Test failure seems unrelated
Comment #39
smustgrave commentedSeems issue summary update and test coverage still missing