Make WordPress Core

Changeset 25396


Ignore:
Timestamp:
09/12/2013 06:56:20 AM (11 years ago)
Author:
dd32
Message:

Fix wp_guess_url() to work in every scenario I could find, allows us to use it to determine the correct path to the WordPress Site URL before installation for install.php and setup-config.php redirects. Fixes #24480 Fixes #16884

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/setup-config.php

    r25173 r25396  
    5555// Turn register_globals off.
    5656wp_unregister_GLOBALS();
     57
     58// Standardize $_SERVER variables across setups.
     59wp_fix_server_vars();
    5760
    5861require_once(ABSPATH . WPINC . '/compat.php');
     
    199202        require_once( ABSPATH . WPINC . '/class-http.php' );
    200203        require_once( ABSPATH . WPINC . '/http.php' );
    201         wp_fix_server_vars();
    202204        /**#@+
    203205         * @ignore
    204206         */
    205207        function get_bloginfo() {
    206             return ( ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . str_replace( $_SERVER['PHP_SELF'], '/wp-admin/setup-config.php', '' ) );
     208            return wp_guess_url();
    207209        }
    208210        /**#@-*/
  • trunk/src/wp-includes/functions.php

    r25371 r25396  
    32323232        $url = WP_SITEURL;
    32333233    } else {
     3234        // The request is for the admin
     3235        if ( strpos( $_SERVER['REQUEST_URI'], 'wp-admin' ) !== false || strpos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false ) {
     3236            $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] );
     3237
     3238        // The request is for a file in ABSPATH
     3239        } elseif ( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/' == ABSPATH ) {
     3240            // Strip off any file/query params in the path
     3241            $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['PHP_SELF'] );
     3242
     3243        } else {
     3244            if ( false !== strpos( $_SERVER['SCRIPT_FILENAME'], ABSPATH ) ) {
     3245                // Request is hitting a file inside ABSPATH
     3246                $directory = str_replace( ABSPATH, '', dirname( $_SERVER['SCRIPT_FILENAME'] ) );
     3247                // Strip off the sub directory, and any file/query paramss
     3248                $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] );
     3249            } else {
     3250                // Request is hitting a file above ABSPATH
     3251                $subdirectory = str_replace( dirname( $_SERVER['SCRIPT_FILENAME'] ), '', ABSPATH );
     3252                // Strip off any file/query params from the path, appending the sub directory to the install
     3253                $path = preg_replace( '#/[^/]*$#i', '' , $_SERVER['REQUEST_URI'] ) . $subdirectory;
     3254            }
     3255        }
     3256
    32343257        $schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet
    3235         $url = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] );
     3258        $url = $schema . $_SERVER['HTTP_HOST'] . $path;
    32363259    }
    32373260
  • trunk/src/wp-includes/load.php

    r25289 r25396  
    446446            wp_die( __( 'The site you have requested is not installed properly. Please contact the system administrator.' ) );
    447447    } elseif ( ! is_blog_installed() && false === strpos( $_SERVER['PHP_SELF'], 'install.php' ) && !defined( 'WP_INSTALLING' ) ) {
    448 
    449         $link = wp_guess_url() . '/wp-admin/install.php';
    450 
    451448        require( ABSPATH . WPINC . '/kses.php' );
    452449        require( ABSPATH . WPINC . '/pluggable.php' );
    453450        require( ABSPATH . WPINC . '/formatting.php' );
     451
     452        $link = wp_guess_url() . '/wp-admin/install.php';
     453
    454454        wp_redirect( $link );
    455455        die();
  • trunk/src/wp-load.php

    r25385 r25396  
    5151    require_once( ABSPATH . WPINC . '/functions.php' );
    5252
    53     // Set a path for the link to the installer
    54     if ( strpos( $_SERVER['PHP_SELF'], 'wp-admin' ) !== false ) {
    55         $path = 'setup-config.php';
    56     } elseif ( file_exists( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/wp-admin/setup-config.php' ) ) {
    57         $path = 'wp-admin/setup-config.php';
    58     } else {
    59         // WordPress files are in a sub directory, and the user is hitting the index.php in the parent directory
    60         $path = str_replace( dirname( $_SERVER['SCRIPT_FILENAME'] ) . '/', '', dirname( __FILE__ ) . '/wp-admin/setup-config.php' );
    61     }
     53    $path = wp_guess_url() . '/wp-admin/setup-config.php';
    6254
    6355    // Die with an error message
Note: See TracChangeset for help on using the changeset viewer.