Plugin Author
Aaron
(@aaron13100)
The casts are there to avoid “Illegal mix of collations” errors. Do you know how I can avoid these and avoid using ‘cast’ ? Or where and how specifically do you think I should change the sql?
thanks
WP docs cover how to make a WP compatible table: https://codex.wordpress.org/Creating_Tables_with_Plugins
example: $charset_collate = $wpdb->get_charset_collate();
WP gives you a function to determine the correct collation when you create a table. For existing tables you can use ALTER TABLE to change it.
https://dev.mysql.com/doc/refman/8.0/en/charset-table.html
Those errors should only happen in cases where the table specified a different collation, or if the wordpress collate differs from the server default and no value was given when creating the table.
Plugin Author
Aaron
(@aaron13100)
The tables where the collation don’t match are the wordpress tables, like wp_posts. Some users have changed their collations to something strange (I remember seeing swedish). So I created some code to read the collations of the wp_posts table and then update all of the collations of the 404solution tables to match whatever that collation is. You can see that code in DatabaseUpgradesEtc.php -> function correctCollations(). It does look like that was done after I added the “cast” stuff though. So maybe the casts aren’t necessary anymore.
It will take some time to try removing the casts and retesting it though. It’s working now so I’m not sure when I might get to that.
Plugin Author
Aaron
(@aaron13100)
Everything seems to be working fine after removing the casts.