Ticket #22134: 22134.patch
File 22134.patch, 7.6 KB (added by , 12 years ago) |
---|
-
schema.php
45 45 $is_multisite = is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ); 46 46 47 47 // Blog specific tables. 48 $blog_tables = "CREATE TABLE $wpdb->terms (48 $blog_tables = "CREATE TABLE IF NOT EXISTS $wpdb->terms ( 49 49 term_id bigint(20) unsigned NOT NULL auto_increment, 50 50 name varchar(200) NOT NULL default '', 51 51 slug varchar(200) NOT NULL default '', … … 54 54 UNIQUE KEY slug (slug), 55 55 KEY name (name) 56 56 ) $charset_collate; 57 CREATE TABLE $wpdb->term_taxonomy (57 CREATE TABLE IF NOT EXISTS $wpdb->term_taxonomy ( 58 58 term_taxonomy_id bigint(20) unsigned NOT NULL auto_increment, 59 59 term_id bigint(20) unsigned NOT NULL default 0, 60 60 taxonomy varchar(32) NOT NULL default '', … … 65 65 UNIQUE KEY term_id_taxonomy (term_id,taxonomy), 66 66 KEY taxonomy (taxonomy) 67 67 ) $charset_collate; 68 CREATE TABLE $wpdb->term_relationships (68 CREATE TABLE IF NOT EXISTS $wpdb->term_relationships ( 69 69 object_id bigint(20) unsigned NOT NULL default 0, 70 70 term_taxonomy_id bigint(20) unsigned NOT NULL default 0, 71 71 term_order int(11) NOT NULL default 0, 72 72 PRIMARY KEY (object_id,term_taxonomy_id), 73 73 KEY term_taxonomy_id (term_taxonomy_id) 74 74 ) $charset_collate; 75 CREATE TABLE $wpdb->commentmeta (75 CREATE TABLE IF NOT EXISTS $wpdb->commentmeta ( 76 76 meta_id bigint(20) unsigned NOT NULL auto_increment, 77 77 comment_id bigint(20) unsigned NOT NULL default '0', 78 78 meta_key varchar(255) default NULL, … … 81 81 KEY comment_id (comment_id), 82 82 KEY meta_key (meta_key) 83 83 ) $charset_collate; 84 CREATE TABLE $wpdb->comments (84 CREATE TABLE IF NOT EXISTS $wpdb->comments ( 85 85 comment_ID bigint(20) unsigned NOT NULL auto_increment, 86 86 comment_post_ID bigint(20) unsigned NOT NULL default '0', 87 87 comment_author tinytext NOT NULL, … … 103 103 KEY comment_date_gmt (comment_date_gmt), 104 104 KEY comment_parent (comment_parent) 105 105 ) $charset_collate; 106 CREATE TABLE $wpdb->links (106 CREATE TABLE IF NOT EXISTS $wpdb->links ( 107 107 link_id bigint(20) unsigned NOT NULL auto_increment, 108 108 link_url varchar(255) NOT NULL default '', 109 109 link_name varchar(255) NOT NULL default '', … … 120 120 PRIMARY KEY (link_id), 121 121 KEY link_visible (link_visible) 122 122 ) $charset_collate; 123 CREATE TABLE $wpdb->options (123 CREATE TABLE IF NOT EXISTS $wpdb->options ( 124 124 option_id bigint(20) unsigned NOT NULL auto_increment, 125 125 option_name varchar(64) NOT NULL default '', 126 126 option_value longtext NOT NULL, … … 128 128 PRIMARY KEY (option_id), 129 129 UNIQUE KEY option_name (option_name) 130 130 ) $charset_collate; 131 CREATE TABLE $wpdb->postmeta (131 CREATE TABLE IF NOT EXISTS $wpdb->postmeta ( 132 132 meta_id bigint(20) unsigned NOT NULL auto_increment, 133 133 post_id bigint(20) unsigned NOT NULL default '0', 134 134 meta_key varchar(255) default NULL, … … 137 137 KEY post_id (post_id), 138 138 KEY meta_key (meta_key) 139 139 ) $charset_collate; 140 CREATE TABLE $wpdb->posts (140 CREATE TABLE IF NOT EXISTS $wpdb->posts ( 141 141 ID bigint(20) unsigned NOT NULL auto_increment, 142 142 post_author bigint(20) unsigned NOT NULL default '0', 143 143 post_date datetime NOT NULL default '0000-00-00 00:00:00', … … 169 169 ) $charset_collate;\n"; 170 170 171 171 // Single site users table. The multisite flavor of the users table is handled below. 172 $users_single_table = "CREATE TABLE $wpdb->users (172 $users_single_table = "CREATE TABLE IF NOT EXISTS $wpdb->users ( 173 173 ID bigint(20) unsigned NOT NULL auto_increment, 174 174 user_login varchar(60) NOT NULL default '', 175 175 user_pass varchar(64) NOT NULL default '', … … 186 186 ) $charset_collate;\n"; 187 187 188 188 // Multisite users table 189 $users_multi_table = "CREATE TABLE $wpdb->users (189 $users_multi_table = "CREATE TABLE IF NOT EXISTS $wpdb->users ( 190 190 ID bigint(20) unsigned NOT NULL auto_increment, 191 191 user_login varchar(60) NOT NULL default '', 192 192 user_pass varchar(64) NOT NULL default '', … … 205 205 ) $charset_collate;\n"; 206 206 207 207 // usermeta 208 $usermeta_table = "CREATE TABLE $wpdb->usermeta (208 $usermeta_table = "CREATE TABLE IF NOT EXISTS $wpdb->usermeta ( 209 209 umeta_id bigint(20) unsigned NOT NULL auto_increment, 210 210 user_id bigint(20) unsigned NOT NULL default '0', 211 211 meta_key varchar(255) default NULL, … … 222 222 $global_tables = $users_single_table . $usermeta_table; 223 223 224 224 // Multisite global tables. 225 $ms_global_tables = "CREATE TABLE $wpdb->blogs (225 $ms_global_tables = "CREATE TABLE IF NOT EXISTS $wpdb->blogs ( 226 226 blog_id bigint(20) NOT NULL auto_increment, 227 227 site_id bigint(20) NOT NULL default '0', 228 228 domain varchar(200) NOT NULL default '', … … 239 239 KEY domain (domain(50),path(5)), 240 240 KEY lang_id (lang_id) 241 241 ) $charset_collate; 242 CREATE TABLE $wpdb->blog_versions (242 CREATE TABLE IF NOT EXISTS $wpdb->blog_versions ( 243 243 blog_id bigint(20) NOT NULL default '0', 244 244 db_version varchar(20) NOT NULL default '', 245 245 last_updated datetime NOT NULL default '0000-00-00 00:00:00', 246 246 PRIMARY KEY (blog_id), 247 247 KEY db_version (db_version) 248 248 ) $charset_collate; 249 CREATE TABLE $wpdb->registration_log (249 CREATE TABLE IF NOT EXISTS $wpdb->registration_log ( 250 250 ID bigint(20) NOT NULL auto_increment, 251 251 email varchar(255) NOT NULL default '', 252 252 IP varchar(30) NOT NULL default '', … … 255 255 PRIMARY KEY (ID), 256 256 KEY IP (IP) 257 257 ) $charset_collate; 258 CREATE TABLE $wpdb->site (258 CREATE TABLE IF NOT EXISTS $wpdb->site ( 259 259 id bigint(20) NOT NULL auto_increment, 260 260 domain varchar(200) NOT NULL default '', 261 261 path varchar(100) NOT NULL default '', 262 262 PRIMARY KEY (id), 263 263 KEY domain (domain,path) 264 264 ) $charset_collate; 265 CREATE TABLE $wpdb->sitemeta (265 CREATE TABLE IF NOT EXISTS $wpdb->sitemeta ( 266 266 meta_id bigint(20) NOT NULL auto_increment, 267 267 site_id bigint(20) NOT NULL default '0', 268 268 meta_key varchar(255) default NULL, … … 271 271 KEY meta_key (meta_key), 272 272 KEY site_id (site_id) 273 273 ) $charset_collate; 274 CREATE TABLE $wpdb->signups (274 CREATE TABLE IF NOT EXISTS $wpdb->signups ( 275 275 domain varchar(200) NOT NULL default '', 276 276 path varchar(100) NOT NULL default '', 277 277 title longtext NOT NULL, … … 308 308 309 309 if ( isset( $old_blog_id ) ) 310 310 $wpdb->set_blog_id( $old_blog_id ); 311 312 return $queries; 311 return $queries; 313 312 } 314 313 315 314 // Populate for back compat. -
upgrade.php
1481 1481 1482 1482 // Create a tablename index for an array ($cqueries) of queries 1483 1483 foreach($queries as $qry) { 1484 if (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) { 1485 $cqueries[ trim( $matches[1], '`' ) ] = $qry; 1486 $for_update[$matches[1]] = 'Created table '.$matches[1]; 1484 if(preg_match("|CREATE TABLE IF NOT EXISTS ([^ ]*)|", $qry, $matches)){ 1485 $cqueries[ trim( $matches[1], '`' ) ] = $qry; 1486 $for_update[$matches[1]] = 'Created table '.$matches[1]; 1487 }elseif (preg_match("|CREATE TABLE ([^ ]*)|", $qry, $matches)) { 1488 $cqueries[ trim( $matches[1], '`' ) ] = $qry; 1489 $for_update[$matches[1]] = 'Created table '.$matches[1]; 1487 1490 } else if (preg_match("|CREATE DATABASE ([^ ]*)|", $qry, $matches)) { 1488 1491 array_unshift($cqueries, $qry); 1489 1492 } else if (preg_match("|INSERT INTO ([^ ]*)|", $qry, $matches)) { … … 1496 1499 } 1497 1500 $cqueries = apply_filters( 'dbdelta_create_queries', $cqueries ); 1498 1501 $iqueries = apply_filters( 'dbdelta_insert_queries', $iqueries ); 1499 1502 1500 1503 $global_tables = $wpdb->tables( 'global' ); 1501 1504 foreach ( $cqueries as $table => $qry ) { 1502 1505 // Upgrade global tables only for the main site. Don't upgrade at all if DO_NOT_UPGRADE_GLOBAL_TABLES is defined.