Changeset 18899
- Timestamp:
- 10/06/2011 12:21:24 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/schema.php
r18878 r18899 8 8 * @subpackage Administration 9 9 */ 10 11 // Declare these as global in case schema.php is included from a function. 12 global $wpdb, $wp_queries, $charset_collate; 10 13 11 14 /** … … 17 20 $charset_collate = ''; 18 21 19 // Declare these as global in case schema.php is included from a function. 20 global $wpdb, $wp_queries; 21 22 if ( ! empty($wpdb->charset) ) 22 if ( ! empty( $wpdb->charset ) ) 23 23 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 24 if ( ! empty( $wpdb->collate) )24 if ( ! empty( $wpdb->collate ) ) 25 25 $charset_collate .= " COLLATE $wpdb->collate"; 26 26 27 /** Create WordPress database tables SQL */ 28 $wp_queries = "CREATE TABLE $wpdb->terms ( 27 /** 28 * Retrieve the SQL for creating database tables. 29 * 30 * @since 3.3.0 31 * 32 * @param string $scope Optional. The tables for which to retrieve SQL. Can be all, global, ms_global, or blog tables. Defaults to all. 33 * @param int $blog_id Optional. The blog ID for which to retrieve SQL. Default is the current blog ID. 34 * @return string The SQL needed to create the requested tables. 35 */ 36 function wp_get_db_schema( $scope = 'all', $blog_id = null ) { 37 global $wpdb; 38 39 if ( ! empty($wpdb->charset) ) 40 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 41 if ( ! empty($wpdb->collate) ) 42 $charset_collate .= " COLLATE $wpdb->collate"; 43 44 if ( $blog_id && $blog_id != $wpdb->blogid ) 45 $old_blog_id = $wpdb->set_blog_id( $blog_id ); 46 47 // Engage multisite if in the middle of turning it on from network.php. 48 $is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ); 49 50 // Blog specific tables. 51 $blog_tables = "CREATE TABLE $wpdb->terms ( 29 52 term_id bigint(20) unsigned NOT NULL auto_increment, 30 53 name varchar(200) NOT NULL default '', … … 149 172 KEY post_parent (post_parent), 150 173 KEY post_author (post_author) 151 ) $charset_collate; 152 CREATE TABLE $wpdb->users ( 174 ) $charset_collate;\n"; 175 176 // Single site users table. The multisite flavor of the users table is handled below. 177 $users_single_table = "CREATE TABLE $wpdb->users ( 153 178 ID bigint(20) unsigned NOT NULL auto_increment, 154 179 user_login varchar(60) NOT NULL default '', … … 164 189 KEY user_login_key (user_login), 165 190 KEY user_nicename (user_nicename) 166 ) $charset_collate; 167 CREATE TABLE $wpdb->usermeta ( 191 ) $charset_collate;\n"; 192 193 // Multisite users table 194 $users_multi_table = "CREATE TABLE $wpdb->users ( 195 ID bigint(20) unsigned NOT NULL auto_increment, 196 user_login varchar(60) NOT NULL default '', 197 user_pass varchar(64) NOT NULL default '', 198 user_nicename varchar(50) NOT NULL default '', 199 user_email varchar(100) NOT NULL default '', 200 user_url varchar(100) NOT NULL default '', 201 user_registered datetime NOT NULL default '0000-00-00 00:00:00', 202 user_activation_key varchar(60) NOT NULL default '', 203 user_status int(11) NOT NULL default '0', 204 display_name varchar(250) NOT NULL default '', 205 spam tinyint(2) NOT NULL default '0', 206 deleted tinyint(2) NOT NULL default '0', 207 PRIMARY KEY (ID), 208 KEY user_login_key (user_login), 209 KEY user_nicename (user_nicename) 210 ) $charset_collate;\n"; 211 212 // usermeta 213 $usermeta_table = "CREATE TABLE $wpdb->usermeta ( 168 214 umeta_id bigint(20) unsigned NOT NULL auto_increment, 169 215 user_id bigint(20) unsigned NOT NULL default '0', … … 173 219 KEY user_id (user_id), 174 220 KEY meta_key (meta_key) 221 ) $charset_collate;\n"; 222 223 // Global tables 224 if ( $is_multisite ) 225 $global_tables = $users_multi_table . $usermeta_table; 226 else 227 $global_tables = $users_single_table . $usermeta_table; 228 229 // Multisite global tables. 230 $ms_global_tables = "CREATE TABLE $wpdb->blogs ( 231 blog_id bigint(20) NOT NULL auto_increment, 232 site_id bigint(20) NOT NULL default '0', 233 domain varchar(200) NOT NULL default '', 234 path varchar(100) NOT NULL default '', 235 registered datetime NOT NULL default '0000-00-00 00:00:00', 236 last_updated datetime NOT NULL default '0000-00-00 00:00:00', 237 public tinyint(2) NOT NULL default '1', 238 archived enum('0','1') NOT NULL default '0', 239 mature tinyint(2) NOT NULL default '0', 240 spam tinyint(2) NOT NULL default '0', 241 deleted tinyint(2) NOT NULL default '0', 242 lang_id int(11) NOT NULL default '0', 243 PRIMARY KEY (blog_id), 244 KEY domain (domain(50),path(5)), 245 KEY lang_id (lang_id) 246 ) $charset_collate; 247 CREATE TABLE $wpdb->blog_versions ( 248 blog_id bigint(20) NOT NULL default '0', 249 db_version varchar(20) NOT NULL default '', 250 last_updated datetime NOT NULL default '0000-00-00 00:00:00', 251 PRIMARY KEY (blog_id), 252 KEY db_version (db_version) 253 ) $charset_collate; 254 CREATE TABLE $wpdb->registration_log ( 255 ID bigint(20) NOT NULL auto_increment, 256 email varchar(255) NOT NULL default '', 257 IP varchar(30) NOT NULL default '', 258 blog_id bigint(20) NOT NULL default '0', 259 date_registered datetime NOT NULL default '0000-00-00 00:00:00', 260 PRIMARY KEY (ID), 261 KEY IP (IP) 262 ) $charset_collate; 263 CREATE TABLE $wpdb->site ( 264 id bigint(20) NOT NULL auto_increment, 265 domain varchar(200) NOT NULL default '', 266 path varchar(100) NOT NULL default '', 267 PRIMARY KEY (id), 268 KEY domain (domain,path) 269 ) $charset_collate; 270 CREATE TABLE $wpdb->sitemeta ( 271 meta_id bigint(20) NOT NULL auto_increment, 272 site_id bigint(20) NOT NULL default '0', 273 meta_key varchar(255) default NULL, 274 meta_value longtext, 275 PRIMARY KEY (meta_id), 276 KEY meta_key (meta_key), 277 KEY site_id (site_id) 278 ) $charset_collate; 279 CREATE TABLE $wpdb->signups ( 280 domain varchar(200) NOT NULL default '', 281 path varchar(100) NOT NULL default '', 282 title longtext NOT NULL, 283 user_login varchar(60) NOT NULL default '', 284 user_email varchar(100) NOT NULL default '', 285 registered datetime NOT NULL default '0000-00-00 00:00:00', 286 activated datetime NOT NULL default '0000-00-00 00:00:00', 287 active tinyint(1) NOT NULL default '0', 288 activation_key varchar(50) NOT NULL default '', 289 meta longtext, 290 KEY activation_key (activation_key), 291 KEY domain (domain) 175 292 ) $charset_collate;"; 293 294 switch ( $scope ) { 295 case 'blog' : 296 $queries = $blog_tables; 297 break; 298 case 'global' : 299 $queries = $global_tables; 300 if ( $is_multisite ) 301 $queries .= $ms_global_tables; 302 break; 303 case 'ms_global' : 304 $queries = $ms_global_tables; 305 break; 306 default: 307 case 'all' : 308 $queries = $global_tables . $blog_tables; 309 if ( $is_multisite ) 310 $queries .= $ms_global_tables; 311 break; 312 } 313 314 if ( isset( $old_blog_id ) ) 315 $wpdb->set_blog_id( $old_blog_id ); 316 317 return $queries; 318 } 319 320 // Populate for back compat. 321 $wp_queries = wp_get_db_schema( 'all' ); 176 322 177 323 /** … … 625 771 626 772 /** 773 * Install Network. 774 * 775 * @since 3.0.0 776 * 777 */ 778 if ( !function_exists( 'install_network' ) ) : 779 function install_network() { 780 if ( ! defined( 'WP_INSTALLING_NETWORK' ) ) 781 define( 'WP_INSTALLING_NETWORK', true ); 782 783 dbDelta( wp_get_db_schema( 'global' ) ); 784 } 785 endif; 786 787 /** 627 788 * populate network settings 628 789 * -
trunk/wp-admin/includes/upgrade.php
r18821 r18899 1425 1425 * @return unknown 1426 1426 */ 1427 function dbDelta( $queries, $execute = true) {1427 function dbDelta( $queries = '', $execute = true ) { 1428 1428 global $wpdb; 1429 1430 if ( in_array( $queries, array( '', 'all', 'blog', 'global', 'ms_global' ), true ) ) 1431 $queries = wp_get_db_schema( $queries ); 1429 1432 1430 1433 // Separate individual queries into an array … … 1632 1635 * @since 1.5.0 1633 1636 */ 1634 function make_db_current() { 1635 global $wp_queries; 1636 1637 $alterations = dbDelta($wp_queries); 1637 function make_db_current( $tables = 'all' ) { 1638 $alterations = dbDelta( $tables ); 1638 1639 echo "<ol>\n"; 1639 1640 foreach($alterations as $alteration) echo "<li>$alteration</li>\n"; … … 1648 1649 * @since 1.5.0 1649 1650 */ 1650 function make_db_current_silent() { 1651 global $wp_queries; 1652 1653 $alterations = dbDelta($wp_queries); 1651 function make_db_current_silent( $tables = 'all' ) { 1652 $alterations = dbDelta( $tables ); 1654 1653 } 1655 1654 … … 1934 1933 1935 1934 /** 1936 * Install Network.1937 *1938 * @since 3.0.01939 *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 tables2027 dbDelta( $ms_queries );2028 }2029 endif;2030 2031 /**2032 1935 * Install global terms. 2033 1936 * -
trunk/wp-admin/network.php
r18841 r18899 11 11 */ 12 12 13 define( 'WP_ NETWORK_ADMIN_PAGE', true );13 define( 'WP_INSTALLING_NETWORK', true ); 14 14 15 15 /** WordPress Administration Bootstrap */ -
trunk/wp-includes/l10n.php
r18827 r18899 383 383 load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" ); 384 384 385 if ( is_multisite() || ( defined( 'WP_ NETWORK_ADMIN_PAGE' ) && WP_NETWORK_ADMIN_PAGE) ) {385 if ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) { 386 386 load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" ); 387 387 } -
trunk/wp-includes/ms-functions.php
r18841 r18899 1173 1173 1174 1174 // Set everything up 1175 make_db_current_silent( );1175 make_db_current_silent( 'blog' ); 1176 1176 populate_options(); 1177 1177 populate_roles();
Note: See TracChangeset
for help on using the changeset viewer.