We had a sql error when we wanted to add a person to a mailing list because of long UTM parameters in the url. The url from which the action was called looked like this:
https://www.karriere.at/lp/gewinnspiel-profil-check?utm_source=newsletter&utm_medium=email&utm_campaign=activesourcing_gewinnspiel_llcheck&utm_content=cta&utm_source=emarsys&utm_medium=email&utm_campaign=B2C+Active+Sourcing+April+2024+-+Lottery+%26+Tips&&sc_src=email_13853398&sc_lid=858156625&sc_uid=wx849sJloR&sc_llid=1484&sc_eh=12e5956964efdaed1
When the form on this url was submitted, a 500 error occurred and we found this error in the logs:
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'source' at row 1
This is how adding the email to the mailing list is implemented:
This hidden input field is in the form:
<input type="hidden" name="action" value="campaign/forms/subscribe" />
When the form gets submitted, it gets validated and this Twig file is called via ajax to determine if this email is already in the email list.
{% set mailingListSlug = craft.app.request.get('mailingList') %}
{% set email = craft.app.request.get('email') %}
{% set contact = craft.campaign.contacts.email(email).one() %}
{% set mailingLists = contact.mailingLists %}
{% set found = false %}
{% for mailingList in mailingLists %}
{% if mailingList.slug == mailingListSlug %}
{% set found = true %}
{% endif %}
{% endfor %}
{{ {
data: found ? contact : null
} | json_encode | raw }}
After everything has been successfully completed, the contact gets added to the mailing list.
Our quick fix was a simple nginx redirect to strip down the get params, but hopefully there is a long term solution for that. If you need more information, feel free to ask. :)
Bug Report
We had a sql error when we wanted to add a person to a mailing list because of long UTM parameters in the url. The url from which the action was called looked like this:
https://www.karriere.at/lp/gewinnspiel-profil-check?utm_source=newsletter&utm_medium=email&utm_campaign=activesourcing_gewinnspiel_llcheck&utm_content=cta&utm_source=emarsys&utm_medium=email&utm_campaign=B2C+Active+Sourcing+April+2024+-+Lottery+%26+Tips&&sc_src=email_13853398&sc_lid=858156625&sc_uid=wx849sJloR&sc_llid=1484&sc_eh=12e5956964efdaed1
When the form on this url was submitted, a 500 error occurred and we found this error in the logs:
SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'source' at row 1
To test this, we truncated the get parameters as follows: https://www.karriere.at/lp/gewinnspiel-profil-check?utm_source=newsletter&utm_medium=email&utm_campaign=activesourcing_gewinnspiel_llcheck&utm_content=cta
This worked without any problems.
This is how adding the email to the mailing list is implemented:
This hidden input field is in the form:
<input type="hidden" name="action" value="campaign/forms/subscribe" />
When the form gets submitted, it gets validated and this Twig file is called via ajax to determine if this email is already in the email list.
Our quick fix was a simple nginx redirect to strip down the get params, but hopefully there is a long term solution for that. If you need more information, feel free to ask. :)
Plugin Version
2.9.2
Craft CMS Version
4.5.11.1
PHP Version
8.2