Make WordPress Core


Ignore:
Timestamp:
05/04/2024 07:23:31 PM (7 months ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r58037 r58097  
    13641364     * (which is to say, when they share the domain name of the current request).
    13651365     */
    1366     if ( is_ssl() && ! str_starts_with( $image_baseurl, 'https' ) && parse_url( $image_baseurl, PHP_URL_HOST ) === $_SERVER['HTTP_HOST'] ) {
    1367         $image_baseurl = set_url_scheme( $image_baseurl, 'https' );
     1366    if ( is_ssl() && ! str_starts_with( $image_baseurl, 'https' ) ) {
     1367        // Since the `Host:` header might contain a port we should
     1368        // compare it against the image URL using the same port.
     1369        $parsed = parse_url( $image_baseurl );
     1370        $domain = $parsed['host'];
     1371        if ( isset( $parsed['port'] ) ) {
     1372            $domain .= ':' . $parsed['port'];
     1373        }
     1374        if ( $_SERVER['HTTP_HOST'] === $domain ) {
     1375            $image_baseurl = set_url_scheme( $image_baseurl, 'https' );
     1376        }
    13681377    }
    13691378
Note: See TracChangeset for help on using the changeset viewer.