Problem/Motivation
Watchdog log have a database exception wrapper for Data too long for column 'subject' at row 1: INSERT INTO "symfony_mailer_log" , this is related to a automated mail that takes the node title and adds some to it. This is the first time we seen this in a very long time with a lot of regular mails so this is probably quite a rare issue.
Steps to reproduce
Sadly I have no good suggestion on how to reproduce this, well except possibly creating a mail with a long subject, in this case it looks to be 310 characters.
Proposed resolution
Before creating a database entry, the data that is to put in should be validated and in cases where it will not fit it should probably be truncated.
Issue fork symfony_mailer_log-3605441
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
svendecabooterI have added logic to update the length of the subject to 1024 characters maximum, which should cover most use cases.
If the subject is still longer than that, it gets truncated.
Comment #6
svendecabooterComment #9
kristofferwiklund commentedThe update hook is not 100% false proof in Drupal 10. There is a problem then settings via
$field_storage_definition->setSetting('max_length', SymfonyMailerLog::SUBJECT_MAX_LENGTH);
It is updating the settings. But when updating the database in
$entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
The schema for the field is geting an old cache version for the schema.
See:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/lib/Drupal/Co...
Solving it for me was to run "drush entup" using https://www.drupal.org/project/devel_entity_updates
Or creating my own update hook.