Multisite: Enforce consistent types on ID columns in multisite database tables, to better allow for foreign keys to more reliably be defined between them.
This change adjusts the install & upgrade routines so all of ID-based database columns in the multisite database tables are `unsigned`, bringing them up-to-speed with ID-based columns in single-site tables. Additionally, the `$wp_db_version` number is bumped, and the `pre_schema_upgrade()` upgrade function is modified to accommodate & use that new version. Follow-up to [10852]. Props spacedmonkey, johnjamesjacoby. Fixes #40418. Built from https://develop.svn.wordpress.org/trunk@60497 git-svn-id: http://core.svn.wordpress.org/trunk@59833 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -245,8 +245,8 @@ CREATE TABLE $wpdb->posts (
|
||||
|
||||
// Multisite global tables.
|
||||
$ms_global_tables = "CREATE TABLE $wpdb->blogs (
|
||||
blog_id bigint(20) NOT NULL auto_increment,
|
||||
site_id bigint(20) NOT NULL default '0',
|
||||
blog_id bigint(20) unsigned NOT NULL auto_increment,
|
||||
site_id bigint(20) unsigned NOT NULL default '0',
|
||||
domain varchar(200) NOT NULL default '',
|
||||
path varchar(100) NOT NULL default '',
|
||||
registered datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
@@ -263,7 +263,7 @@ CREATE TABLE $wpdb->posts (
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->blogmeta (
|
||||
meta_id bigint(20) unsigned NOT NULL auto_increment,
|
||||
blog_id bigint(20) NOT NULL default '0',
|
||||
blog_id bigint(20) unsigned NOT NULL default '0',
|
||||
meta_key varchar(255) default NULL,
|
||||
meta_value longtext,
|
||||
PRIMARY KEY (meta_id),
|
||||
@@ -271,24 +271,24 @@ CREATE TABLE $wpdb->blogmeta (
|
||||
KEY blog_id (blog_id)
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->registration_log (
|
||||
ID bigint(20) NOT NULL auto_increment,
|
||||
ID bigint(20) unsigned NOT NULL auto_increment,
|
||||
email varchar(255) NOT NULL default '',
|
||||
IP varchar(30) NOT NULL default '',
|
||||
blog_id bigint(20) NOT NULL default '0',
|
||||
blog_id bigint(20) unsigned NOT NULL default '0',
|
||||
date_registered datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
PRIMARY KEY (ID),
|
||||
KEY IP (IP)
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->site (
|
||||
id bigint(20) NOT NULL auto_increment,
|
||||
id bigint(20) unsigned NOT NULL auto_increment,
|
||||
domain varchar(200) NOT NULL default '',
|
||||
path varchar(100) NOT NULL default '',
|
||||
PRIMARY KEY (id),
|
||||
KEY domain (domain(140),path(51))
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->sitemeta (
|
||||
meta_id bigint(20) NOT NULL auto_increment,
|
||||
site_id bigint(20) NOT NULL default '0',
|
||||
meta_id bigint(20) unsigned NOT NULL auto_increment,
|
||||
site_id bigint(20) unsigned NOT NULL default '0',
|
||||
meta_key varchar(255) default NULL,
|
||||
meta_value longtext,
|
||||
PRIMARY KEY (meta_id),
|
||||
@@ -296,7 +296,7 @@ CREATE TABLE $wpdb->sitemeta (
|
||||
KEY site_id (site_id)
|
||||
) $charset_collate;
|
||||
CREATE TABLE $wpdb->signups (
|
||||
signup_id bigint(20) NOT NULL auto_increment,
|
||||
signup_id bigint(20) unsigned NOT NULL auto_increment,
|
||||
domain varchar(200) NOT NULL default '',
|
||||
path varchar(100) NOT NULL default '',
|
||||
title longtext NOT NULL,
|
||||
|
||||
@@ -3711,7 +3711,7 @@ function pre_schema_upgrade() {
|
||||
}
|
||||
|
||||
// Multisite schema upgrades.
|
||||
if ( $wp_current_db_version < 25448 && is_multisite() && wp_should_upgrade_global_tables() ) {
|
||||
if ( $wp_current_db_version < 60497 && is_multisite() && wp_should_upgrade_global_tables() ) {
|
||||
|
||||
// Upgrade versions prior to 3.7.
|
||||
if ( $wp_current_db_version < 25179 ) {
|
||||
@@ -3725,6 +3725,20 @@ function pre_schema_upgrade() {
|
||||
$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived varchar(1) NOT NULL default '0'" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->blogs CHANGE COLUMN archived archived tinyint(2) NOT NULL default 0" );
|
||||
}
|
||||
|
||||
// Upgrade versions prior to 6.9
|
||||
if ( $wp_current_db_version < 60497 ) {
|
||||
// Convert ID columns from signed to unsigned
|
||||
$wpdb->query( "ALTER TABLE $wpdb->blogs MODIFY blog_id bigint(20) unsigned NOT NULL auto_increment" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->blogs MODIFY site_id bigint(20) unsigned NOT NULL default 0" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->blogmeta MODIFY blog_id bigint(20) unsigned NOT NULL default 0" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->registration_log MODIFY ID bigint(20) unsigned NOT NULL auto_increment" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->registration_log MODIFY blog_id bigint(20) unsigned NOT NULL default 0" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->site MODIFY id bigint(20) unsigned NOT NULL auto_increment" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->sitemeta MODIFY meta_id bigint(20) unsigned NOT NULL auto_increment" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->sitemeta MODIFY site_id bigint(20) unsigned NOT NULL default 0" );
|
||||
$wpdb->query( "ALTER TABLE $wpdb->signups MODIFY signup_id bigint(20) unsigned NOT NULL auto_increment" );
|
||||
}
|
||||
}
|
||||
|
||||
// Upgrade versions prior to 4.2.
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.9-alpha-60496';
|
||||
$wp_version = '6.9-alpha-60497';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
*
|
||||
* @global int $wp_db_version
|
||||
*/
|
||||
$wp_db_version = 60421;
|
||||
$wp_db_version = 60497;
|
||||
|
||||
/**
|
||||
* Holds the TinyMCE version.
|
||||
|
||||
Reference in New Issue
Block a user