Make WordPress Core

Ticket #12028: 12028.3.diff

File 12028.3.diff, 13.4 KB (added by ryan, 13 years ago)
  • wp-includes/l10n.php

     
    382382
    383383        load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );
    384384
    385         if ( is_multisite() || ( defined( 'WP_NETWORK_ADMIN_PAGE' ) && WP_NETWORK_ADMIN_PAGE ) ) {
     385        if ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) {
    386386                load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" );
    387387        }
    388388}
  • wp-includes/ms-functions.php

     
    11721172        $url = get_blogaddress_by_id($blog_id);
    11731173
    11741174        // Set everything up
    1175         make_db_current_silent();
     1175        make_db_current_silent( 'blog' );
    11761176        populate_options();
    11771177        populate_roles();
    11781178        $wp_roles->_init();
  • wp-admin/network.php

     
    1010 * @subpackage Administration
    1111 */
    1212
    13 define( 'WP_NETWORK_ADMIN_PAGE', true );
     13define( 'WP_INSTALLING_NETWORK', true );
    1414
    1515/** WordPress Administration Bootstrap */
    1616require_once( './admin.php' );
  • wp-admin/includes/upgrade.php

     
    14241424 * @param unknown_type $execute
    14251425 * @return unknown
    14261426 */
    1427 function dbDelta($queries, $execute = true) {
     1427function dbDelta( $queries = '', $execute = true ) {
    14281428        global $wpdb;
    14291429
     1430        if ( empty( $queries ) )
     1431                $queries = wp_get_db_schema( 'all' );
     1432        elseif ( 'all' == $queries )
     1433                $queries = wp_get_db_schema( 'all' );
     1434        elseif ( 'blog' == $queries )
     1435                $queries = wp_get_db_schema( 'blog' );
     1436        elseif ( 'global' == $queries )
     1437                $queries = wp_get_db_schema( 'global' );
     1438        elseif ( 'ms' == $queries )
     1439                $queries = wp_get_db_schema( 'ms' );
     1440
    14301441        // Separate individual queries into an array
    14311442        if ( !is_array($queries) ) {
    14321443                $queries = explode( ';', $queries );
     
    16311642 *
    16321643 * @since 1.5.0
    16331644 */
    1634 function make_db_current() {
    1635         global $wp_queries;
    1636 
    1637         $alterations = dbDelta($wp_queries);
     1645function make_db_current( $tables = 'all' ) {
     1646        $alterations = dbDelta( $tables );
    16381647        echo "<ol>\n";
    16391648        foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
    16401649        echo "</ol>\n";
     
    16471656 *
    16481657 * @since 1.5.0
    16491658 */
    1650 function make_db_current_silent() {
    1651         global $wp_queries;
    1652 
    1653         $alterations = dbDelta($wp_queries);
     1659function make_db_current_silent(  $tables = 'all' ) {
     1660        $alterations = dbDelta( $tables );
    16541661}
    16551662
    16561663/**
     
    19331940}
    19341941
    19351942/**
    1936  * Install Network.
    1937  *
    1938  * @since 3.0.0
    1939  *
    1940  */
    1941 if ( !function_exists( 'install_network' ) ) :
    1942 function install_network() {
    1943         global $wpdb, $charset_collate;
    1944         $ms_queries = "
    1945 CREATE TABLE $wpdb->users (
    1946   ID bigint(20) unsigned NOT NULL auto_increment,
    1947   user_login varchar(60) NOT NULL default '',
    1948   user_pass varchar(64) NOT NULL default '',
    1949   user_nicename varchar(50) NOT NULL default '',
    1950   user_email varchar(100) NOT NULL default '',
    1951   user_url varchar(100) NOT NULL default '',
    1952   user_registered datetime NOT NULL default '0000-00-00 00:00:00',
    1953   user_activation_key varchar(60) NOT NULL default '',
    1954   user_status int(11) NOT NULL default '0',
    1955   display_name varchar(250) NOT NULL default '',
    1956   spam tinyint(2) NOT NULL default '0',
    1957   deleted tinyint(2) NOT NULL default '0',
    1958   PRIMARY KEY  (ID),
    1959   KEY user_login_key (user_login),
    1960   KEY user_nicename (user_nicename)
    1961 ) $charset_collate;
    1962 CREATE TABLE $wpdb->blogs (
    1963   blog_id bigint(20) NOT NULL auto_increment,
    1964   site_id bigint(20) NOT NULL default '0',
    1965   domain varchar(200) NOT NULL default '',
    1966   path varchar(100) NOT NULL default '',
    1967   registered datetime NOT NULL default '0000-00-00 00:00:00',
    1968   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
    1969   public tinyint(2) NOT NULL default '1',
    1970   archived enum('0','1') NOT NULL default '0',
    1971   mature tinyint(2) NOT NULL default '0',
    1972   spam tinyint(2) NOT NULL default '0',
    1973   deleted tinyint(2) NOT NULL default '0',
    1974   lang_id int(11) NOT NULL default '0',
    1975   PRIMARY KEY  (blog_id),
    1976   KEY domain (domain(50),path(5)),
    1977   KEY lang_id (lang_id)
    1978 ) $charset_collate;
    1979 CREATE TABLE $wpdb->blog_versions (
    1980   blog_id bigint(20) NOT NULL default '0',
    1981   db_version varchar(20) NOT NULL default '',
    1982   last_updated datetime NOT NULL default '0000-00-00 00:00:00',
    1983   PRIMARY KEY  (blog_id),
    1984   KEY db_version (db_version)
    1985 ) $charset_collate;
    1986 CREATE TABLE $wpdb->registration_log (
    1987   ID bigint(20) NOT NULL auto_increment,
    1988   email varchar(255) NOT NULL default '',
    1989   IP varchar(30) NOT NULL default '',
    1990   blog_id bigint(20) NOT NULL default '0',
    1991   date_registered datetime NOT NULL default '0000-00-00 00:00:00',
    1992   PRIMARY KEY  (ID),
    1993   KEY IP (IP)
    1994 ) $charset_collate;
    1995 CREATE TABLE $wpdb->site (
    1996   id bigint(20) NOT NULL auto_increment,
    1997   domain varchar(200) NOT NULL default '',
    1998   path varchar(100) NOT NULL default '',
    1999   PRIMARY KEY  (id),
    2000   KEY domain (domain,path)
    2001 ) $charset_collate;
    2002 CREATE TABLE $wpdb->sitemeta (
    2003   meta_id bigint(20) NOT NULL auto_increment,
    2004   site_id bigint(20) NOT NULL default '0',
    2005   meta_key varchar(255) default NULL,
    2006   meta_value longtext,
    2007   PRIMARY KEY  (meta_id),
    2008   KEY meta_key (meta_key),
    2009   KEY site_id (site_id)
    2010 ) $charset_collate;
    2011 CREATE TABLE $wpdb->signups (
    2012   domain varchar(200) NOT NULL default '',
    2013   path varchar(100) NOT NULL default '',
    2014   title longtext NOT NULL,
    2015   user_login varchar(60) NOT NULL default '',
    2016   user_email varchar(100) NOT NULL default '',
    2017   registered datetime NOT NULL default '0000-00-00 00:00:00',
    2018   activated datetime NOT NULL default '0000-00-00 00:00:00',
    2019   active tinyint(1) NOT NULL default '0',
    2020   activation_key varchar(50) NOT NULL default '',
    2021   meta longtext,
    2022   KEY activation_key (activation_key),
    2023   KEY domain (domain)
    2024 ) $charset_collate;
    2025 ";
    2026 // now create tables
    2027         dbDelta( $ms_queries );
    2028 }
    2029 endif;
    2030 
    2031 /**
    20321943 * Install global terms.
    20331944 *
    20341945 * @since 3.0.0
  • wp-admin/includes/schema.php

     
    88 * @subpackage Administration
    99 */
    1010
     11// Declare these as global in case schema.php is included from a function.
     12global $wpdb, $wp_queries;
     13
    1114/**
    12  * The database character collate.
    13  * @var string
    14  * @global string
    15  * @name $charset_collate
     15 * Retrieve the SQL for creating database tables.
     16 *
     17 * @since 3.3.0
     18 *
     19 * @param string $scope Optional. The tables for which to retrieve SQL. Can be all, global, ms_global, or blog tables. Defaults to all.
     20 * @param int $blog_id Optional. The blog ID for which to retrieve SQL.  Default is the current blog ID.
     21 * @return string The SQL needed to create the requested tables.
    1622 */
    17 $charset_collate = '';
     23function wp_get_db_schema( $scope = 'all', $blog_id = null ) {
     24        global $wpdb;
    1825
    19 // Declare these as global in case schema.php is included from a function.
    20 global $wpdb, $wp_queries;
     26        if ( ! empty($wpdb->charset) )
     27                $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
     28        if ( ! empty($wpdb->collate) )
     29                $charset_collate .= " COLLATE $wpdb->collate";
    2130
    22 if ( ! empty($wpdb->charset) )
    23         $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
    24 if ( ! empty($wpdb->collate) )
    25         $charset_collate .= " COLLATE $wpdb->collate";
     31        if ( $blog_id && $blog_id != $wpdb->blogid )
     32                $old_blog_id = $wpdb->set_blog_id( $blog_id );
    2633
    27 /** Create WordPress database tables SQL */
    28 $wp_queries = "CREATE TABLE $wpdb->terms (
     34        // Engage multisite if in the middle of turning it on from network.php.
     35        $is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK );
     36
     37        // Blog specific tables.
     38        $blog_tables = "CREATE TABLE $wpdb->terms (
    2939 term_id bigint(20) unsigned NOT NULL auto_increment,
    3040 name varchar(200) NOT NULL default '',
    3141 slug varchar(200) NOT NULL default '',
     
    148158  KEY type_status_date (post_type,post_status,post_date,ID),
    149159  KEY post_parent (post_parent),
    150160  KEY post_author (post_author)
    151 ) $charset_collate;
    152 CREATE TABLE $wpdb->users (
     161) $charset_collate;\n";
     162
     163        // Single site users table. The multisite flavor of the users table is handled below.
     164        $users_single_table = "CREATE TABLE $wpdb->users (
    153165  ID bigint(20) unsigned NOT NULL auto_increment,
    154166  user_login varchar(60) NOT NULL default '',
    155167  user_pass varchar(64) NOT NULL default '',
     
    163175  PRIMARY KEY  (ID),
    164176  KEY user_login_key (user_login),
    165177  KEY user_nicename (user_nicename)
    166 ) $charset_collate;
    167 CREATE TABLE $wpdb->usermeta (
     178) $charset_collate;\n";
     179
     180        // Multisite users table
     181        $users_multi_table = "CREATE TABLE $wpdb->users (
     182  ID bigint(20) unsigned NOT NULL auto_increment,
     183  user_login varchar(60) NOT NULL default '',
     184  user_pass varchar(64) NOT NULL default '',
     185  user_nicename varchar(50) NOT NULL default '',
     186  user_email varchar(100) NOT NULL default '',
     187  user_url varchar(100) NOT NULL default '',
     188  user_registered datetime NOT NULL default '0000-00-00 00:00:00',
     189  user_activation_key varchar(60) NOT NULL default '',
     190  user_status int(11) NOT NULL default '0',
     191  display_name varchar(250) NOT NULL default '',
     192  spam tinyint(2) NOT NULL default '0',
     193  deleted tinyint(2) NOT NULL default '0',
     194  PRIMARY KEY  (ID),
     195  KEY user_login_key (user_login),
     196  KEY user_nicename (user_nicename)
     197) $charset_collate;\n";
     198
     199        // usermeta
     200        $usermeta_table = "CREATE TABLE $wpdb->usermeta (
    168201  umeta_id bigint(20) unsigned NOT NULL auto_increment,
    169202  user_id bigint(20) unsigned NOT NULL default '0',
    170203  meta_key varchar(255) default NULL,
     
    172205  PRIMARY KEY  (umeta_id),
    173206  KEY user_id (user_id),
    174207  KEY meta_key (meta_key)
     208) $charset_collate;\n";
     209
     210        // Global tables
     211        if ( $is_multisite )
     212                $global_tables = $users_multi_table . $usermeta_table;
     213        else
     214                $global_tables = $users_single_table . $usermeta_table;
     215
     216        // Multisite global tables.
     217        $ms_global_tables = "CREATE TABLE $wpdb->blogs (
     218  blog_id bigint(20) NOT NULL auto_increment,
     219  site_id bigint(20) NOT NULL default '0',
     220  domain varchar(200) NOT NULL default '',
     221  path varchar(100) NOT NULL default '',
     222  registered datetime NOT NULL default '0000-00-00 00:00:00',
     223  last_updated datetime NOT NULL default '0000-00-00 00:00:00',
     224  public tinyint(2) NOT NULL default '1',
     225  archived enum('0','1') NOT NULL default '0',
     226  mature tinyint(2) NOT NULL default '0',
     227  spam tinyint(2) NOT NULL default '0',
     228  deleted tinyint(2) NOT NULL default '0',
     229  lang_id int(11) NOT NULL default '0',
     230  PRIMARY KEY  (blog_id),
     231  KEY domain (domain(50),path(5)),
     232  KEY lang_id (lang_id)
     233) $charset_collate;
     234CREATE TABLE $wpdb->blog_versions (
     235  blog_id bigint(20) NOT NULL default '0',
     236  db_version varchar(20) NOT NULL default '',
     237  last_updated datetime NOT NULL default '0000-00-00 00:00:00',
     238  PRIMARY KEY  (blog_id),
     239  KEY db_version (db_version)
     240) $charset_collate;
     241CREATE TABLE $wpdb->registration_log (
     242  ID bigint(20) NOT NULL auto_increment,
     243  email varchar(255) NOT NULL default '',
     244  IP varchar(30) NOT NULL default '',
     245  blog_id bigint(20) NOT NULL default '0',
     246  date_registered datetime NOT NULL default '0000-00-00 00:00:00',
     247  PRIMARY KEY  (ID),
     248  KEY IP (IP)
     249) $charset_collate;
     250CREATE TABLE $wpdb->site (
     251  id bigint(20) NOT NULL auto_increment,
     252  domain varchar(200) NOT NULL default '',
     253  path varchar(100) NOT NULL default '',
     254  PRIMARY KEY  (id),
     255  KEY domain (domain,path)
     256) $charset_collate;
     257CREATE TABLE $wpdb->sitemeta (
     258  meta_id bigint(20) NOT NULL auto_increment,
     259  site_id bigint(20) NOT NULL default '0',
     260  meta_key varchar(255) default NULL,
     261  meta_value longtext,
     262  PRIMARY KEY  (meta_id),
     263  KEY meta_key (meta_key),
     264  KEY site_id (site_id)
     265) $charset_collate;
     266CREATE TABLE $wpdb->signups (
     267  domain varchar(200) NOT NULL default '',
     268  path varchar(100) NOT NULL default '',
     269  title longtext NOT NULL,
     270  user_login varchar(60) NOT NULL default '',
     271  user_email varchar(100) NOT NULL default '',
     272  registered datetime NOT NULL default '0000-00-00 00:00:00',
     273  activated datetime NOT NULL default '0000-00-00 00:00:00',
     274  active tinyint(1) NOT NULL default '0',
     275  activation_key varchar(50) NOT NULL default '',
     276  meta longtext,
     277  KEY activation_key (activation_key),
     278  KEY domain (domain)
    175279) $charset_collate;";
    176280
     281        switch ( $scope ) {
     282                case 'blog' :
     283                        $queries = $blog_tables;
     284                        break;
     285                case 'global' :
     286                        $queries = $global_tables;
     287                        if ( $is_multisite )
     288                                $queries .= $ms_global_tables;
     289                        break;
     290                case 'ms_global' :
     291                        $queries = $ms_global_tables;
     292                        break;
     293                default:
     294                case 'all' :
     295                        $queries = $global_tables . $blog_tables;
     296                        if ( $is_multisite )
     297                                $queries .= $ms_global_tables;
     298                        break;
     299        }
     300
     301        if ( isset( $old_blog_id ) )
     302                $wpdb->set_blog_id( $old_blog_id );
     303
     304        return $queries;
     305}
     306
     307// Populate for back compat.
     308$wp_queries = wp_get_db_schema( 'all' );
     309
    177310/**
    178311 * Create WordPress options and set the default values.
    179312 *
     
    624757}
    625758
    626759/**
     760 * Install Network.
     761 *
     762 * @since 3.0.0
     763 *
     764 */
     765if ( !function_exists( 'install_network' ) ) :
     766function install_network() {
     767        if ( ! defined( 'WP_INSTALLING_NETWORK' ) )
     768                define( 'WP_INSTALLING_NETWORK', true );
     769
     770        dbDelta( wp_get_db_schema( 'global' ) );
     771}
     772endif;
     773
     774/**
    627775 * populate network settings
    628776 *
    629777 * @since 3.0.0