Make WordPress Core

Ticket #47733: 47733.diff

File 47733.diff, 1.4 KB (added by Mte90, 4 months ago)

adding patch also here so I can find the ticket inside trac as contributor

  • src/wp-includes/ms-settings.php

    diff --git a/src/wp-includes/ms-settings.php b/src/wp-includes/ms-settings.php
    index 6824895880f..3b7fd6d32eb 100644
    a b  
    5454// have not been populated in the global scope through something like `sunrise.php`.
    5555if ( ! isset( $current_site ) || ! isset( $current_blog ) ) {
    5656
    57         $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) );
    58         if ( ':80' === substr( $domain, -3 ) ) {
    59                 $domain               = substr( $domain, 0, -3 );
    60                 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
    61         } elseif ( ':443' === substr( $domain, -4 ) ) {
    62                 $domain               = substr( $domain, 0, -4 );
    63                 $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
     57        $domain = 'notdefined';
     58
     59        if ( isset( $_SERVER['SERVER_NAME'] ) && ! empty( $_SERVER['SERVER_NAME'] ) ) {
     60                $domain = $_SERVER['SERVER_NAME'];
     61        }
     62
     63        if ( isset( $_SERVER['HTTP_HOST'] ) ) {
     64                $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) );
     65                if ( ':80' === substr( $domain, -3 ) ) {
     66                        $domain               = substr( $domain, 0, -3 );
     67                        $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 );
     68                } elseif ( ':443' === substr( $domain, -4 ) ) {
     69                        $domain               = substr( $domain, 0, -4 );
     70                        $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 );
     71                }
    6472        }
    6573
    6674        $path = stripslashes( $_SERVER['REQUEST_URI'] );