Bootstrap/Load: Add support for custom ports in multisite site addresses.
This allows a Multisite network to use an address that includes a port name, such as `example.com:1234`, and adds support for this to the local development environment too. You can now run a Multisite installation on the local development environment, for example at `localhost:8889`. This also fixes some bugs with running a single site installation on a port, and updates the testing infrastructure so that the whole test suite runs both with and without a port number. Props djzone, scribu, nacin, ipstenu, F J Kaiser, jeremyfelt, johnjamesjacoby, spacedmonkey, PerS, Clorith, Blackbam, enrico.sorcinelli, Jules Colle, obliviousharmony, desrosj, johnbillion Fixes #21077, #52088 Built from https://develop.svn.wordpress.org/trunk@58097 git-svn-id: http://core.svn.wordpress.org/trunk@57562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -66,8 +66,14 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
|
||||
}
|
||||
|
||||
$blog_data['scheme'] = $update_parsed_url['scheme'];
|
||||
|
||||
// Make sure to not lose the port if it was provided.
|
||||
$blog_data['domain'] = $update_parsed_url['host'];
|
||||
$blog_data['path'] = $update_parsed_url['path'];
|
||||
if ( isset( $update_parsed_url['port'] ) ) {
|
||||
$blog_data['domain'] .= ':' . $update_parsed_url['port'];
|
||||
}
|
||||
|
||||
$blog_data['path'] = $update_parsed_url['path'];
|
||||
}
|
||||
|
||||
$existing_details = get_site( $id );
|
||||
@@ -88,16 +94,18 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
|
||||
|
||||
$old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
|
||||
$old_home_parsed = parse_url( $old_home_url );
|
||||
$old_home_host = $old_home_parsed['host'] . ( isset( $old_home_parsed['port'] ) ? ':' . $old_home_parsed['port'] : '' );
|
||||
|
||||
if ( $old_home_parsed['host'] === $existing_details->domain && $old_home_parsed['path'] === $existing_details->path ) {
|
||||
if ( $old_home_host === $existing_details->domain && $old_home_parsed['path'] === $existing_details->path ) {
|
||||
$new_home_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
|
||||
update_option( 'home', $new_home_url );
|
||||
}
|
||||
|
||||
$old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
|
||||
$old_site_parsed = parse_url( $old_site_url );
|
||||
$old_site_host = $old_site_parsed['host'] . ( isset( $old_site_parsed['port'] ) ? ':' . $old_site_parsed['port'] : '' );
|
||||
|
||||
if ( $old_site_parsed['host'] === $existing_details->domain && $old_site_parsed['path'] === $existing_details->path ) {
|
||||
if ( $old_site_host === $existing_details->domain && $old_site_parsed['path'] === $existing_details->path ) {
|
||||
$new_site_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
|
||||
update_option( 'siteurl', $new_site_url );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user