Consider field name length instead of the fixed value of 255 characters

Created on 11 April 2023, about 1 year ago
Updated 12 April 2023, about 1 year ago

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.

✨ Feature request
Status

Needs review

Version

2.0

Component

Code

Created by

πŸ‡§πŸ‡·Brazil rrmontuan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024