Field length smaller than 11 results in error

Created on 2 September 2019, over 5 years ago
Updated 26 September 2024, 7 months ago

Problem / motivation

I tend to use the max length property in the field storage settings.
This set the form fields maxlength property and also performs a validation before the form submits.
Now, settings the length to under 11, gives the error
Drupal\Core\Entity\EntityStorageException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_xXx_value' at row 1:
This due to the fact that the default encrypted text is: [ENCRYPTED]

Proposed solution

Check for the max_length setting from the field definition and shorten the unencrypted value to that length.

Dependencies

Tests did no longer pass, and I added new test for this case. General test adaptions are applied in this issues patch and separately here: #3079620: Make tests run again

🐛 Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

🇨🇭Switzerland ytsurk Switzerland

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024