Problem/Motivation
When we add a term with more than 255 characters, the name is always truncated to 255 characters, even if the term name field is able to store more than 255 characters, either updating the DB schema or using a module like title_length, for example.
Steps to reproduce
- Create a new Term Vocabulary.
- Install the module title_length (composer require 'drupal/title_length:^2.0@RC').
- Activate the module title_length and the submodule taxonomy_term_title_length (doing this, the term name field will increase to 500 characters)
- Add the term below (with 446 characters) to the vocabulary using the Taxonomy Manager.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
This way, the term will be truncated to 255 characters even with the field name being able to store 500 characters.

Proposed resolution
We could use the service entity.last_installed_schema.repository to get the last installed storage definitions for taxonomy_term, using the method getLastInstalledFieldStorageDefinitions. This way, we will be able to retrieve the definitions for the field name and then, the setting max_length, containing the current value, equals 500.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | consider_field_name_length-3353522-3.patch | 5.22 KB | rrmontuan |
| Captura de tela de 2023-04-11 15-32-13.png | 75.2 KB | rrmontuan |
Issue fork taxonomy_manager-3353522
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
rrmontuanIgnore this patch, it was created for the 2.0.4 version.
Comment #3
rrmontuanComment #4
rrmontuanIgnore this patch, some adjustments were needed.
Comment #5
rrmontuanComment #6
rrmontuanHey, guys!
I did the changes accordingly to the proposed resolution.
Please, review it.
Thanks!
Comment #7
rrmontuanComment #10
sokru commentedConverted the patch from #6 into merge request and made minor coding standard fixes. Tested manually to be working, although I leave it up to maintainers if they require tests for this.
Comment #13
vladimirausThank you! Commited!