WordPress.org

Make WordPress Core

Changeset 4860


Ignore:
Timestamp:
02/02/2007 12:04:35 AM (13 years ago)
Author:
ryan
Message:

First cut at mysql utf-8 charset suport. Props to sehh, drupal, and textpattern. fixes #3517

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/upgrade-schema.php

    r4832 r4860  
    11<?php
    22// Here we keep the DB structure and option values
     3
     4$charset_collate = '';
     5   
     6if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
     7    if ( ! empty($wpdb->charset) )
     8        $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     9    if ( ! empty($wpdb->collate) )
     10        $charset_collate .= " COLLATE $wpdb->collate"; 
     11}
    312
    413$wp_queries="CREATE TABLE $wpdb->categories (
     
    1423  PRIMARY KEY  (cat_ID),
    1524  KEY category_nicename (category_nicename)
    16 );
     25) $charset_collate;
    1726CREATE TABLE $wpdb->comments (
    1827  comment_ID bigint(20) unsigned NOT NULL auto_increment,
     
    3443  KEY comment_approved (comment_approved),
    3544  KEY comment_post_ID (comment_post_ID)
    36 );
     45) $charset_collate;
    3746CREATE TABLE $wpdb->link2cat (
    3847  rel_id bigint(20) NOT NULL auto_increment,
     
    4150  PRIMARY KEY  (rel_id),
    4251  KEY link_id (link_id,category_id)
    43 );
     52) $charset_collate;
    4453CREATE TABLE $wpdb->links (
    4554  link_id bigint(20) NOT NULL auto_increment,
     
    6069  KEY link_category (link_category),
    6170  KEY link_visible (link_visible)
    62 );
     71) $charset_collate;
    6372CREATE TABLE $wpdb->options (
    6473  option_id bigint(20) NOT NULL auto_increment,
     
    7584  PRIMARY KEY  (option_id,blog_id,option_name),
    7685  KEY option_name (option_name)
    77 );
     86) $charset_collate;
    7887CREATE TABLE $wpdb->post2cat (
    7988  rel_id bigint(20) NOT NULL auto_increment,
     
    8291  PRIMARY KEY  (rel_id),
    8392  KEY post_id (post_id,category_id)
    84 );
     93) $charset_collate;
    8594CREATE TABLE $wpdb->postmeta (
    8695  meta_id bigint(20) NOT NULL auto_increment,
     
    91100  KEY post_id (post_id),
    92101  KEY meta_key (meta_key)
    93 );
     102) $charset_collate;
    94103CREATE TABLE $wpdb->posts (
    95104  ID bigint(20) unsigned NOT NULL auto_increment,
     
    120129  KEY post_name (post_name),
    121130  KEY type_status_date (post_type,post_status,post_date,ID)
    122 );
     131) $charset_collate;
    123132CREATE TABLE $wpdb->users (
    124133  ID bigint(20) unsigned NOT NULL auto_increment,
     
    134143  PRIMARY KEY  (ID),
    135144  KEY user_login_key (user_login)
    136 );
     145) $charset_collate;
    137146CREATE TABLE $wpdb->usermeta (
    138147  umeta_id bigint(20) NOT NULL auto_increment,
     
    143152  KEY user_id (user_id),
    144153  KEY meta_key (meta_key)
    145 );";
     154) $charset_collate;";
    146155
    147156function populate_options() {
  • trunk/wp-config-sample.php

    r4424 r4860  
    55define('DB_PASSWORD', 'password'); // ...and password
    66define('DB_HOST', 'localhost');    // 99% chance you won't need to change this value
     7define('DB_CHARSET', 'utf8');
     8define('DB_COLLATE', 'utf8_general_ci');
    79
    810// You can have multiple installations in one database if you give each a unique prefix
  • trunk/wp-includes/version.php

    r4859 r4860  
    44
    55$wp_version = '2.2-bleeding';
    6 $wp_db_version = 4859;
     6$wp_db_version = 4860;
    77
    88?>
  • trunk/wp-includes/wp-db.php

    r4832 r4860  
    3636    var $postmeta;
    3737
     38    var $charset;
     39    var $collate;
     40
    3841    /**
    3942     * Connects to the database server and selects a database
     
    4952    function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
    5053        register_shutdown_function(array(&$this, "__destruct"));
     54
     55        if ( defined('DB_CHARSET') )
     56            $this->charset = DB_CHARSET;
     57
     58        if ( defined('DB_COLLATE') )
     59            $this->collate = DB_COLLATE;
    5160
    5261        $this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
     
    6372");
    6473        }
     74
     75        if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') )
     76            $this->query("SET NAMES '$this->charset'");
    6577
    6678        $this->select($dbname);
Note: See TracChangeset for help on using the changeset viewer.