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:
parent
2637a3d194
commit
9feb8a6925
|
@ -148,26 +148,8 @@ function network_step1( $errors = false ) {
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
$hostname = get_clean_basedomain();
|
// Strip standard port from hostname.
|
||||||
$has_ports = strstr( $hostname, ':' );
|
$hostname = preg_replace( '/(?::80|:443)$/', '', get_clean_basedomain() );
|
||||||
if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ), true ) ) ) {
|
|
||||||
wp_admin_notice(
|
|
||||||
'<strong>' . __( 'Error:' ) . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ),
|
|
||||||
array(
|
|
||||||
'additional_classes' => array( 'error' ),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
echo '<p>' . sprintf(
|
|
||||||
/* translators: %s: Port number. */
|
|
||||||
__( 'You cannot use port numbers such as %s.' ),
|
|
||||||
'<code>' . $has_ports . '</code>'
|
|
||||||
) . '</p>';
|
|
||||||
echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Go to Dashboard' ) . '</a>';
|
|
||||||
echo '</div>';
|
|
||||||
require_once ABSPATH . 'wp-admin/admin-footer.php';
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '<form method="post">';
|
echo '<form method="post">';
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,13 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$blog_data['scheme'] = $update_parsed_url['scheme'];
|
$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['domain'] = $update_parsed_url['host'];
|
||||||
|
if ( isset( $update_parsed_url['port'] ) ) {
|
||||||
|
$blog_data['domain'] .= ':' . $update_parsed_url['port'];
|
||||||
|
}
|
||||||
|
|
||||||
$blog_data['path'] = $update_parsed_url['path'];
|
$blog_data['path'] = $update_parsed_url['path'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,16 +94,18 @@ if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] ) {
|
||||||
|
|
||||||
$old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
|
$old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
|
||||||
$old_home_parsed = parse_url( $old_home_url );
|
$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 ) );
|
$new_home_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
|
||||||
update_option( 'home', $new_home_url );
|
update_option( 'home', $new_home_url );
|
||||||
}
|
}
|
||||||
|
|
||||||
$old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
|
$old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
|
||||||
$old_site_parsed = parse_url( $old_site_url );
|
$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 ) );
|
$new_site_url = untrailingslashit( sanitize_url( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
|
||||||
update_option( 'siteurl', $new_site_url );
|
update_option( 'siteurl', $new_site_url );
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,12 +627,13 @@ function get_oembed_response_data_for_url( $url, $args ) {
|
||||||
wp_parse_url( $url ),
|
wp_parse_url( $url ),
|
||||||
array(
|
array(
|
||||||
'host' => '',
|
'host' => '',
|
||||||
|
'port' => null,
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$qv = array(
|
$qv = array(
|
||||||
'domain' => $url_parts['host'],
|
'domain' => $url_parts['host'] . ( $url_parts['port'] ? ':' . $url_parts['port'] : '' ),
|
||||||
'path' => '/',
|
'path' => '/',
|
||||||
'update_site_meta_cache' => false,
|
'update_site_meta_cache' => false,
|
||||||
);
|
);
|
||||||
|
|
|
@ -660,8 +660,14 @@ function rss2_site_icon() {
|
||||||
* @return string Correct link for the atom:self element.
|
* @return string Correct link for the atom:self element.
|
||||||
*/
|
*/
|
||||||
function get_self_link() {
|
function get_self_link() {
|
||||||
$host = parse_url( home_url() );
|
$parsed = parse_url( home_url() );
|
||||||
return set_url_scheme( 'http://' . $host['host'] . wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
|
||||||
|
$domain = $parsed['host'];
|
||||||
|
if ( isset( $parsed['port'] ) ) {
|
||||||
|
$domain .= ':' . $parsed['port'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return set_url_scheme( 'http://' . $domain . wp_unslash( $_SERVER['REQUEST_URI'] ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1363,9 +1363,18 @@ function wp_calculate_image_srcset( $size_array, $image_src, $image_meta, $attac
|
||||||
* If currently on HTTPS, prefer HTTPS URLs when we know they're supported by the domain
|
* If currently on HTTPS, prefer HTTPS URLs when we know they're supported by the domain
|
||||||
* (which is to say, when they share the domain name of the current request).
|
* (which is to say, when they share the domain name of the current request).
|
||||||
*/
|
*/
|
||||||
if ( is_ssl() && ! str_starts_with( $image_baseurl, 'https' ) && parse_url( $image_baseurl, PHP_URL_HOST ) === $_SERVER['HTTP_HOST'] ) {
|
if ( is_ssl() && ! str_starts_with( $image_baseurl, 'https' ) ) {
|
||||||
|
// Since the `Host:` header might contain a port we should
|
||||||
|
// compare it against the image URL using the same port.
|
||||||
|
$parsed = parse_url( $image_baseurl );
|
||||||
|
$domain = $parsed['host'];
|
||||||
|
if ( isset( $parsed['port'] ) ) {
|
||||||
|
$domain .= ':' . $parsed['port'];
|
||||||
|
}
|
||||||
|
if ( $_SERVER['HTTP_HOST'] === $domain ) {
|
||||||
$image_baseurl = set_url_scheme( $image_baseurl, 'https' );
|
$image_baseurl = set_url_scheme( $image_baseurl, 'https' );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Images that have been edited in WordPress after being uploaded will
|
* Images that have been edited in WordPress after being uploaded will
|
||||||
|
|
|
@ -524,11 +524,7 @@ function wp_prepare_site_data( $data, $defaults, $old_site = null ) {
|
||||||
function wp_normalize_site_data( $data ) {
|
function wp_normalize_site_data( $data ) {
|
||||||
// Sanitize domain if passed.
|
// Sanitize domain if passed.
|
||||||
if ( array_key_exists( 'domain', $data ) ) {
|
if ( array_key_exists( 'domain', $data ) ) {
|
||||||
$data['domain'] = trim( $data['domain'] );
|
$data['domain'] = preg_replace( '/[^a-z0-9\-.:]+/i', '', $data['domain'] );
|
||||||
$data['domain'] = preg_replace( '/\s+/', '', sanitize_user( $data['domain'], true ) );
|
|
||||||
if ( is_subdomain_install() ) {
|
|
||||||
$data['domain'] = str_replace( '@', '', $data['domain'] );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sanitize path if passed.
|
// Sanitize path if passed.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.6-alpha-58096';
|
$wp_version = '6.6-alpha-58097';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue