This PR changes the DB charset and collate from utf8 to utf8mb4. We achieve this for 2 user stories: A. New users (fresh plugin install) and B. Existing users (plugin update).
For new users, we change the CREATE table query to use $wpdb->collate. And for existing users, we provide a UI (upgrade button) in "Settings" that when clicked by the user, will perform the ALTER TABLE query. We do it like this for existing users instead of automatically, informing the user and instructing them to make a backup of their database before performing the ALTER TABLE query.
While it shouldn't have any problems since utf8 is a subset of utf8mb4, it's always best to have a backup ready before doing any DB table alteration.
This PR also includes a fix where we delete other options and a transient when "Cleanup" is toggled on and the plugin is de-activated.
Motivation
Fixes #151 and #144.
Testing procedure
For new / fresh install
Activate the plugin.
Send an email with non-utf8 characters such as emojis 🚀🚢 🥳 .
Check that the email with emoji is logged.
For existing users (plugin update)
Navigate to your Dashboard -> WP Mail Logging -> Email Log.
You should see a warning admin notice. P.S. You should also see this on the SMTP page.
When you click the link in the warning notice, you'll be redirected to the Settings page where you'll see Database Upgrade. Click the "Upgrade" button
You'll see a success notice once the DB migration succeeded.
Test by sending an email with emoji. You should see that the email is logged.
Description
This PR changes the DB charset and collate from
utf8
toutf8mb4
. We achieve this for 2 user stories: A. New users (fresh plugin install) and B. Existing users (plugin update).For new users, we change the
CREATE
table query to use$wpdb->collate
. And for existing users, we provide a UI (upgrade button) in "Settings" that when clicked by the user, will perform theALTER TABLE
query. We do it like this for existing users instead of automatically, informing the user and instructing them to make a backup of their database before performing theALTER TABLE
query.While it shouldn't have any problems since
utf8
is a subset ofutf8mb4
, it's always best to have a backup ready before doing any DB table alteration.This PR also includes a fix where we delete other options and a transient when "Cleanup" is toggled on and the plugin is de-activated.
Motivation
Fixes #151 and #144.
Testing procedure
For new / fresh install
For existing users (plugin update)