We get the following exception when adding a tag that is too long:

Drupal\Core\Entity\EntityStorageException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'name' at row 1: INSERT INTO {taxonomy_term_field_data} (tid, vid, langcode, name, description__value, description__format, weight, changed, default_langcode) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => 8 [:db_insert_placeholder_1] => tags [:db_insert_placeholder_2] => en [:db_insert_placeholder_3] => volutpat tortor. Aenean sit amet risus ante. Etiam sit amet nisi id risus interdum congue. Duis ut erat non orci pulvinar ultricies vitae ut nulla. Nullam vehicula hendrerit pretium. Nullam sit amet sapien et massa gravida venenatis eu sit amet ipsum. Nulla dapibus metus lorem [:db_insert_placeholder_4] => [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => 0 [:db_insert_placeholder_7] => 1442409979 [:db_insert_placeholder_8] => 1 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 757 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).

We need to add a validation for this.

Comments

edurenye created an issue. See original summary.

jespermb’s picture

I confirmed the bug and created a patch for it. I will check if this also applies to other entity reference selection widgets.

Do we need a test for this?

jespermb’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: add-length-validation-for-tagging-2569549-2.patch, failed testing.

The last submitted patch, 2: add-length-validation-for-tagging-2569549-2.patch, failed testing.

berdir’s picture

Component: node system » entity_reference.module

You are missing the parent call. And yes,we need a test.

I'm also wondering if we should solve this using the entity validation API, but I'm not sure what will happen if we have required fields and so on terms.

jespermb’s picture

I will see if I can't write a test for this or find someone who can help me.

It could be argued that we should do it with entity validation instead, unfortunately I don't have the overview to clarify the consequences. If someone could point me in the right direction maybe i could investigate it?

jespermb’s picture

Status: Needs work » Needs review
amateescu’s picture

Status: Needs review » Closed (duplicate)