From d02ac3536a2d10f71249d487c62ab0a43eec5281 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 16 Sep 2025 13:16:40 +1000 Subject: [PATCH 1/4] Increase length of IP field to account for IPv6 --- src/wp-admin/includes/schema.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 971ea71767f09..46df17a749e6b 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -274,7 +274,7 @@ function wp_get_db_schema( $scope = 'all', $blog_id = null ) { CREATE TABLE $wpdb->registration_log ( ID bigint(20) unsigned NOT NULL auto_increment, email varchar(255) NOT NULL default '', - IP varchar(30) NOT NULL default '', + IP varchar(39) NOT NULL default '', blog_id bigint(20) unsigned NOT NULL default '0', date_registered datetime NOT NULL default '0000-00-00 00:00:00', PRIMARY KEY (ID), From 1a3edadfe3d8447fb40f50dc0265e457ed0ee503 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 16 Sep 2025 13:18:06 +1000 Subject: [PATCH 2/4] Update IP address sanitization to accept IPv6 --- src/wp-includes/ms-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index 74337328d13d7..bd8ec50b69399 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -2104,7 +2104,7 @@ function wpmu_log_new_registrations( $blog_id, $user_id ) { $wpdb->registration_log, array( 'email' => $user->user_email, - 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), + 'IP' => preg_replace( '/[^a-f0-9:., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time( 'mysql' ), ) From f9ec707679784c1daf72c81c445584a7795d9217 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Tue, 16 Sep 2025 13:21:19 +1000 Subject: [PATCH 3/4] Update the schema update to account for the changed table. --- src/wp-admin/includes/upgrade.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index e206152e842ed..c1cdf02467b2a 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -3741,7 +3741,7 @@ function pre_schema_upgrade() { } // Multisite schema upgrades. - if ( $wp_current_db_version < 60497 && is_multisite() && wp_should_upgrade_global_tables() ) { + if ( $wp_current_db_version < 60498 && is_multisite() && wp_should_upgrade_global_tables() ) { // TODO: Update with commit. // Upgrade versions prior to 3.7. if ( $wp_current_db_version < 25179 ) { @@ -3769,6 +3769,9 @@ function pre_schema_upgrade() { $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" ); } + if ( $wp_current_db_version < 60498 ) { // TODO: Update with commit. + $wpdb->query( "ALTER TABLE $wpdb->registration_log MODIFY IP varchar(39) NOT NULL default ''" ); + } } // Upgrade versions prior to 4.2. From 4d245265b0a07673d70498feed90999fedddc1b9 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 20 Feb 2026 09:59:00 +1000 Subject: [PATCH 4/4] Strip non-ip-characters --- src/wp-includes/ms-functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index bd8ec50b69399..2890d3a443d64 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -2104,7 +2104,7 @@ function wpmu_log_new_registrations( $blog_id, $user_id ) { $wpdb->registration_log, array( 'email' => $user->user_email, - 'IP' => preg_replace( '/[^a-f0-9:., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), + 'IP' => preg_replace( '/[^a-f0-9:.]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time( 'mysql' ), )