500 Error When Saving Emails - Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException

Your software
My Mautic version is: 4.2.1
My PHP version is: 7.4.28
My Database type and version is: MariaDB 10.5

Your problem
My problem is: Emails produce a 500 server error when saving or editing.

Secondary problem (related) Clicking on ‘Database info’ in System Info results in no action (database info does not load).

These errors are showing in the log:
[2022-04-13 11:42:56] mautic.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occurred while executing ‘INSERT INTO emails (is_published, date_added, created_by, created_by_user, date_modified, modified_by, modified_by_user, checked_out, checked_out_by, checked_out_by_user, name, description, subject, from_address, from_name, reply_to_address, bcc_address, use_owner_as_mailer, template, content, utm_tags, plain_text, custom_html, email_type, publish_up, publish_down, read_count, sent_count, variant_sent_count, variant_read_count, revision, lang, variant_settings, variant_start_date, dynamic_content, headers, public_preview, category_id, translation_parent_id, variant_parent_id, unsubscribeform_id, preference_center_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)’ with params [MY PARAMS “a:0:{}”, “a:4:{s:9:“utmSource”;N;s:9:“utmMedium”;N;s:11:“utmCampaign”;N;s:10:“utmContent”;N;}”, null, "\r\n\r\n\r\n\r\n

[2022-04-13 00:02:23] mautic.NOTICE: PHP Notice - SessionHandler::gc(): ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied (13) - in file /var/www/html/vendor/symfony/http-foundation/Session/Storage/Handler/StrictSessionHandler.php - at line 106 {“maxlifetime”:1440}

Steps I have tried to fix the problem:
Cleared cache
Updated schema
Checked for outstanding database migrations
Fixed permissions for /var/lib/php/sessions
Restarted apache
Rebooted server

Thank you for any advice.

I have further narrowed down the issue…

The 500 errors are triggered only when text is pasted into the email. If you write text by hand, they save.

This is really bizarre, but it reproduces 100% of the time for me. Tried on multiple devices, browsers, internet connections, and users.

I have determined it’s the emojis that are causing the error. I assume this is a database issue, but I’m unsure of a fix. Any pointers?

This is solved.

Somehow the db was converted to utf8 during a recent MariaDB upgrade. The solution was to convert back to utf8mb4