WordPress.org

Make WordPress Core

Ticket #15936: ms-settings_201301082151.patch

File ms-settings_201301082151.patch, 1.2 KB (added by F J Kaiser, 5 years ago)

Takes $_SERVER['SERVER_NAME'] also into account. Works with current (3.5) version. Fixes the global $domain.

  • wp-includes/ms-settings.php

     
    2222
    2323if ( !isset( $current_site ) || !isset( $current_blog ) ) {
    2424
     25        // We don't know if $_SERVER['HTTP_HOST'] or $_SERVER['SERVER_NAME'] is set
     26        $domain = $_SERVER['HTTP_HOST'];
     27        if ( ! isset( $domain ) && ! empty( $_SERVER['SERVER_NAME'] ) ) {
     28                $domain = $_SERVER['SERVER_NAME'];
     29        }
     30        $domain = preg_replace( '|:\d+$|', '', $domain );
    2531        $domain = addslashes( $_SERVER['HTTP_HOST'] );
    26         if ( false !== strpos( $domain, ':' ) ) {
    27                 if ( substr( $domain, -3 ) == ':80' ) {
    28                         $domain = substr( $domain, 0, -3 );
    29                         $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
    30                 } elseif ( substr( $domain, -4 ) == ':443' ) {
    31                         $domain = substr( $domain, 0, -4 );
    32                         $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
    33                 } else {
    34                         wp_load_translations_early();
    35                         wp_die( __( 'Multisite only works without the port number in the URL.' ) );
    36                 }
    37         }
     32        $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = $domain;
    3833
    3934        $domain = rtrim( $domain, '.' );
    4035        $cookie_domain = $domain;