Ralev
Sophomore
Just Getting Started
Member Likes (0)
Hello there,
Having Membership on a localhost enviroment for testing revealed that charset in not set when creating plugin's tables. My mySQL is apparently falling back to latin_swedish_cias default. All that caused my cyrillic inputs transformed into ????? characters. An easy fix is to rely on $wpdb->charset and $wpdb->collate to make sure all stored data is utf8_general_ci encoded.
Example from upgrade.php:
global $wpdb;
$charset_collate = '';
if ( ! empty($wpdb->charset) )
$charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
if ( ! empty($wpdb->collate) )
$charset_collate .= " COLLATE $wpdb->collate";
$sql = "CREATE TABLE IF NOT EXISTS " . membership_db_prefix($wpdb, 'pings') . " (
id bigint(20) NOT NULL auto_increment,
pingname varchar(250) default NULL,
pinginfo text,
pingtype varchar(10) default NULL,
PRIMARY KEY (id)
) $charset_collate;";

Responses (3)
Inactive (joined February 2012) Likes (0)
Hello Ralev,
Thanks for sharing this, will make sure Barry gets this :)
Cheers!
Member (joined April 2011) Likes (0)
Sadly this didn't make it in latest update :(
Inactive (joined February 2012) Likes (0)
Maybe he missed it, I will send him another email right away :)
Become a member