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.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | add-length-validation-for-tagging-2569549-7.patch | 923 bytes | jespermb |
| #2 | add-length-validation-for-tagging-2569549-2.patch | 805 bytes | jespermb |
Comments
Comment #2
jespermb commentedI 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?
Comment #3
jespermb commentedComment #6
berdirYou 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.
Comment #7
jespermb commentedI 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?
Comment #8
jespermb commentedComment #9
amateescu commentedWe're fixing this in #2438017: Entity reference does not validate auto-created entities :)