WordPress.org

Make WordPress Core

Changeset 13641


Ignore:
Timestamp:
03/10/10 08:17:07 (4 years ago)
Author:
nacin
Message:

Correct subdomain handling in network.php. Pass around boolean values instead of 'yes' and 'no'. see #11816

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/schema.php

    r13636 r13641  
    621621 * @param int $network_id id of network to populate 
    622622 */ 
    623 function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $vhost = 'no' ) { 
     623function populate_network( $network_id = 1, $domain = '', $email = '', $site_name = '', $path = '/', $subdomain_install = false ) { 
    624624    global $wpdb, $current_site, $wp_db_version, $wp_rewrite; 
    625625 
     
    733733    } 
    734734 
    735     if ( $vhost == 'yes' ) 
     735    if ( $subdomain_install ) 
    736736        update_option( 'permalink_structure', '/%year%/%monthnum%/%day%/%postname%/'); 
    737737    else 
     
    740740    $wp_rewrite->flush_rules(); 
    741741 
    742     if ( $vhost == 'yes' ) { 
     742    if ( $subdomain_install ) { 
    743743        $vhost_ok = false; 
    744744        $hostname = substr( md5( time() ), 0, 6 ) . '.' . $domain; // Very random hostname! 
    745745        $page = wp_remote_get( 'http://' . $hostname, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); 
    746         if ( is_object( $page ) && is_wp_error( $page ) ) { 
     746        if ( is_wp_error( $page ) ) { 
    747747            foreach ( $page->get_error_messages() as $err ) { 
    748748                $errstr = $err; 
     
    751751                $vhost_ok = true; 
    752752        } 
    753         if ( !$vhost_ok ) { 
     753        if ( ! $vhost_ok ) { 
    754754            // @todo Update this to reflect the merge. Also: Multisite readme file, or remove the <blockquote> tags. 
    755755            $msg = '<h2>' . esc_html__( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</h2>'; 
  • trunk/wp-admin/network.php

    r13638 r13641  
    9999        <table class="form-table"> 
    100100            <tr> 
    101                 <th><label><input type='radio' name='vhost' value='yes'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th> 
     101                <th><label><input type='radio' name='subdomain_install' value='1'<?php checked( $rewrite_enabled ); ?> /> Sub-domains</label></th> 
    102102                <td><?php _e('like <code>site1.example.com</code> and <code>site2.example.com</code>'); ?></td> 
    103103            </tr> 
    104104            <tr> 
    105                 <th><label><input type='radio' name='vhost' value='no'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th> 
     105                <th><label><input type='radio' name='subdomain_install' value='0'<?php checked( ! $rewrite_enabled ); ?> /> Sub-directories</label></th> 
    106106                <td><?php _e('like <code>example.com/site1</code> and <code>example.com/site2</code>'); ?></td> 
    107107            </tr> 
     
    169169function network_step2() { 
    170170    global $base, $wpdb; 
    171     if ( ! $_POST ) : 
    172         if ( is_multisite() ) : ?> 
     171    if ( $_POST ) { 
     172        $vhost = (bool) $_POST['subdomain_install']; 
     173    } else { 
     174        if ( is_multisite() ) { 
     175            $vhost = is_subdomain_install(); 
     176?> 
    173177    <div class="updated"><p><strong><?php _e( 'Notice: The Network feature is already enabled.' ); ?></strong> <?php _e( 'The original configuration steps are shown here for reference.' ); ?></p></div> 
    174 <?php   else : ?> 
     178<?php   } else { 
     179            $vhost = false; // @todo. 
     180?> 
    175181    <div class="error"><p><strong><?php _e('Warning:'); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div> 
    176182    <p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p> 
     
    179185        <div class="updated inline"><p><?php _e( '<strong>Caution:</strong> We recommend you backup your existing <code>wp-config.php</code> and <code>.htaccess</code> files.' ); ?></p></div> 
    180186<?php 
    181         endif; 
    182     endif; 
     187        } 
     188    } 
    183189?> 
    184190        <ol> 
     
    187193                <textarea class="code" readonly="readonly" cols="100" rows="7"> 
    188194define( 'MULTISITE', true ); 
    189 define( 'VHOST', '<?php echo ( ! empty( $_POST['vhost'] ) && 'yes' == stripslashes( $_POST['vhost'] ) ) ? 'yes' : 'no'; ?>' ); 
     195define( 'VHOST', '<?php echo $vhost ? 'yes' : 'no'; ?>' ); 
    190196$base = '<?php echo $base; ?>'; 
    191197define( 'DOMAIN_CURRENT_SITE', '<?php echo get_clean_basedomain(); ?>' ); 
     
    260266} 
    261267 
     268$base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) ); 
     269 
    262270if ( $_POST ) { 
    263271    check_admin_referer( 'install-network-1' ); 
    264  
    265     // Install! 
    266     $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) ); 
    267272 
    268273    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 
     
    270275    install_network(); 
    271276    $hostname = get_clean_basedomain(); 
    272     $vhost = 'localhost' == $hostname ? false : (bool) $_POST['vhost']; 
     277    $subdomain_install = 'localhost' == $hostname ? false : (bool) $_POST['subdomain_install']; 
    273278    if ( ! network_domain_check() ) 
    274         populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $vhost ); 
     279        populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), $_POST['weblog_title'], $base, $subdomain_install ); 
    275280    // create wp-config.php / htaccess 
    276281    network_step2(); 
Note: See TracChangeset for help on using the changeset viewer.