WordPress.org

Make WordPress Core

Ticket #23073: 23073.4.2.diff

File 23073.4.2.diff, 1.6 KB (added by SergeyBiryukov, 5 years ago)
  • wp-admin/network.php

     
    309309function network_step2( $errors = false ) {
    310310        global $wpdb;
    311311
     312        $home_path         = get_home_path();
    312313        $hostname          = get_clean_basedomain();
    313314        $slashed_home      = trailingslashit( get_option( 'home' ) );
    314315        $base              = parse_url( $slashed_home, PHP_URL_PATH );
    315         $wp_dir_from_root  = preg_replace( '#^' . preg_quote( $_SERVER['DOCUMENT_ROOT'], '#' ) . '#', '', ABSPATH );
    316         $wp_siteurl_subdir = trailingslashit( '/' . preg_replace( '#^' . preg_quote( $base, '#' ) . '#', '', $wp_dir_from_root ) );
     316        $document_root     = str_replace( '\\', '/', realpath( $_SERVER['DOCUMENT_ROOT'] ) );
     317        $sanitized_abspath = str_replace( '\\', '/', ABSPATH );
     318        if ( 0 === strpos( $sanitized_abspath, $document_root ) ) {
     319                $wp_dir_from_root  = preg_replace( '#^' . preg_quote( $document_root, '#' ) . '#', '', $sanitized_abspath );
     320                $wp_siteurl_subdir = trailingslashit( '/' . preg_replace( '#^' . preg_quote( $base, '#' ) . '#', '', $wp_dir_from_root ) );
     321        } else {
     322                $wp_siteurl_subdir = preg_replace( '#^' . preg_quote( $home_path, '#' ) . '#', '', ABSPATH );
     323        }
    317324        $rewrite_base      = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : '';
    318325
    319         $home_path         = get_home_path();
    320 
    321326        $location_of_wp_config = ABSPATH;
    322327        if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) )
    323328                $location_of_wp_config = trailingslashit( dirname( ABSPATH ) );