Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypted Field Data Too Long #2036

Open
joelzerner opened this issue Aug 25, 2024 · 8 comments
Open

Encrypted Field Data Too Long #2036

joelzerner opened this issue Aug 25, 2024 · 8 comments

Comments

@joelzerner
Copy link

Describe the bug

I've noticed this error occurring after updating to v2.1.26 - when submitting a phone number to an encrypted field, the encrypted data that's trying to save to the database is too long for the VARCHAR field at 255 characters. For now I've manually boosted this to 500 to avoid errors. I've done this for the encrypted email field too.
Is 255 the intended length for an encrypted field? Should we increase this to avoid the errors?
Happy to provide further details if needed.

SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_phone_qdxwmyno' at row 1

Steps to reproduce

  1. Create a form with an encrypted phone number field
  2. Test form submission with a phone number between 12-15 digits/characters long

Form settings

  • Multi-page form: Yes or No
  • Submission Method: Ajax or Page Reload
  • Client-side Validation: Yes or No
  • Custom Form Templates: Yes or No

Craft CMS version

4.11.4

Plugin version

2.1.26

Multi-site?

No

Additional context

No response

@engram-design
Copy link
Member

For now, I'd recommend setting the enableLargeFieldStorage configuration setting that will bump up the column to TEXT.

However, what's a bit odd is that we already have this handling setup for when you use content encryption.

@joelzerner
Copy link
Author

Thanks. I may be missing it in an obvious spot but I cannot find the enableLargeFieldStorage setting on the page you linked to or anywhere when searching the docs?

Ok, if you've already got the field conversion to text handled for content encryption then I'm happy to see this as a one-off random occurrence and I will just update them manually.

@engram-design
Copy link
Member

It's more of a hidden setting at the moment, as it's been removed in Formie 3 for Craft 5 (it's no longer required), but it's not going anywhere for Formie 2/Craft 4.

But yes, re-saving the form should re-save each field, and update the content column used. But it should've done that anyway when you saved the form with the content encryption. Unless this was a recent upgrade and the field hasn't been updated for some time.

@joelzerner
Copy link
Author

We were running v2.1.3 previously and only just updated to v2.1.26 yesterday, so that may explain it?

I tried re-saving a form with an encrypted field and checked to see if it had automatically updated the table column but it was still a VARCHAR not a TEXT unfortunately.

@engram-design
Copy link
Member

I don't believe there's been any changes since then, so you should be all good on that front.

So that's odd behaviour. I've created a new form, and toggling on/off the "Enable Content Encryption" setting is changing the column in the content table from TEXT to VARCHAR as I'd expect (I don't have enableLargeFieldStorage enabled just for testing). You're not seeing that? What's your database engine and version?

@joelzerner
Copy link
Author

MariaDB 11.5.2
I did the same on a form with two encrypted fields - email and phone.
I converted them back to normal fields and saved the form. They were both VARCHAR.
Then I converted them back to encrypted fields and saved the form. Email is still VARCHAR but Phone has changed to TEXT.

@engram-design
Copy link
Member

Right, so Phone fields are working now, but not Email fields. We have the very same handling setup for all fields, including an Email field, so I'm not sure what's going on there...

@joelzerner
Copy link
Author

All good. I'm happy to leave it and I can do it manually. It seems it's set up correctly in the codebase!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants