IPv6 support for multisite wp_registration_log - #9911
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
Since the description notes the change is "untested and only validated on a visual review", here's a regression test for the core behavior — an IPv6 Goes in /**
* Ensures an IPv6 remote address is preserved when logging a registration.
*
* @ticket 63986
*/
public function test_wpmu_log_new_registrations_preserves_ipv6_address() {
global $wpdb;
$ipv6 = '2001:0db8:85a3:0000:0000:8a2e:0370:7334';
$original_remote_addr = isset( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : null;
$_SERVER['REMOTE_ADDR'] = $ipv6;
try {
wpmu_log_new_registrations( 1, 1 );
$logged_ip = $wpdb->get_var( "SELECT IP FROM {$wpdb->registration_log} WHERE blog_id = 1 ORDER BY ID DESC LIMIT 1" );
} finally {
if ( null === $original_remote_addr ) {
unset( $_SERVER['REMOTE_ADDR'] );
} else {
$_SERVER['REMOTE_ADDR'] = $original_remote_addr;
}
}
$this->assertSame(
$ipv6,
$logged_ip,
'The IPv6 remote address was not stored intact in the registration log.'
);
}Run with |
There was a problem hiding this comment.
Pull request overview
Adds IPv6 compatibility for multisite registration logging by expanding the stored IP format and updating the multisite schema/upgrade path accordingly.
Changes:
- Allow IPv6 characters when storing
$_SERVER['REMOTE_ADDR']intowp_registration_log. - Expand
registration_log.IPcolumn width fromvarchar(30)tovarchar(39)in the multisite schema. - Add a multisite upgrade step intended to widen the existing
registration_log.IPcolumn.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/wp-includes/ms-functions.php |
Updates IP sanitization for wpmu_log_new_registrations() to better accommodate IPv6. |
src/wp-admin/includes/upgrade.php |
Adds a multisite schema upgrade step to widen the registration_log.IP column (version-gated). |
src/wp-admin/includes/schema.php |
Updates the multisite schema definition so new installs create registration_log.IP as varchar(39). |
Comments suppressed due to low confidence (1)
src/wp-admin/includes/upgrade.php:3775
- Indentation of this query line is inconsistent with the surrounding block (extra tab), which makes the upgrade code harder to read and violates the file’s existing formatting.
$wpdb->query( "ALTER TABLE $wpdb->registration_log MODIFY IP varchar(39) NOT NULL default ''" );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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'] ) ), |
|
|
||
| // 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. |
Trac ticket: https://core.trac.wordpress.org/ticket/63986#ticket
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.