Make WordPress Core

Ticket #33909: 33909.6.diff

File 33909.6.diff, 2.6 KB (added by fgirardey, 9 years ago)

Fix the installation process for WP_HOME and fix the blog installation for the siteurl

  • src/wp-admin/includes/schema.php

    From b3f2e25df3339736a9feeaa818c538e03ffc4b9a Mon Sep 17 00:00:00 2001
    From: fgirardey <fgirardey@groupeforum.net>
    Date: Tue, 22 Sep 2015 09:24:50 +0200
    Subject: [PATCH] Use WP_HOME in `populate_options` Use the network siteurl
     path in `install_blog`
    
    ---
     src/wp-admin/includes/schema.php |  7 +++++--
     src/wp-includes/ms-functions.php | 13 +++++++++++--
     2 files changed, 16 insertions(+), 4 deletions(-)
    
    diff --git src/wp-admin/includes/schema.php src/wp-admin/includes/schema.php
    index dd36834..561f082 100644
    $wp_queries = wp_get_db_schema( 'all' ); 
    344344function populate_options() {
    345345        global $wpdb, $wp_db_version, $wp_current_db_version;
    346346
    347         $guessurl = wp_guess_url();
     347        $guessurl = $homeurl = wp_guess_url();
     348        if ( defined( 'WP_HOME' ) && ! empty( WP_HOME ) ) { // wp_guess_url() checked WP_SITEURL constant.
     349                $homeurl = rtrim( WP_HOME, '/' );
     350        }
    348351        /**
    349352         * Fires before creating WordPress options and populating their default values.
    350353         *
    function populate_options() { 
    379382
    380383        $options = array(
    381384        'siteurl' => $guessurl,
    382         'home' => $guessurl,
     385        'home' => $homeurl,
    383386        'blogname' => __('My Site'),
    384387        /* translators: blog tagline */
    385388        'blogdescription' => __('Just another WordPress site'),
  • src/wp-includes/ms-functions.php

    diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php
    index aedc36c..499e3db 100644
    function install_blog( $blog_id, $blog_title = '' ) { 
    13971397                die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
    13981398        $wpdb->suppress_errors( $suppress );
    13991399
    1400         $url = get_blogaddress_by_id( $blog_id );
     1400        $url = $siteurl = get_blogaddress_by_id( $blog_id );
     1401
     1402        // Get the correct siteurl path based on the main network
     1403        if ( is_subdomain_install() ) {
     1404                $network_siteurl = parse_url( get_blog_option( get_main_network_id(), 'siteurl' ) );
     1405                if ( isset( $network_siteurl['path'] ) ) {
     1406                        $siteurl = untrailingslashit( $siteurl ) . $network_siteurl['path'];
     1407                }
     1408        }
    14011409
    14021410        // Set everything up
    14031411        make_db_current_silent( 'blog' );
    function install_blog( $blog_id, $blog_title = '' ) { 
    14081416        $wp_roles = new WP_Roles();
    14091417
    14101418        $url = untrailingslashit( $url );
     1419        $siteurl = untrailingslashit( $siteurl );
    14111420
    1412         update_option( 'siteurl', $url );
     1421        update_option( 'siteurl', $siteurl );
    14131422        update_option( 'home', $url );
    14141423
    14151424        if ( get_site_option( 'ms_files_rewriting' ) )