Make WordPress Core


Ignore:
Timestamp:
10/15/2012 09:41:29 PM (11 years ago)
Author:
ryan
Message:

In populate_network(), distinguish between upgrading from single to multisite and creating a new network in an existing multisite environment. When creating a new network steps related to setting up the main site must be skipped since the main site is created after populate_network() runs. Further, the global should not be modified since populating a new network does not involve switching to that network and making it current. fixes #22090

File:
1 edited

Legend:

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

    r22006 r22240  
    927927    $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
    928928
    929     $current_site = new stdClass;
    930     $current_site->domain = $domain;
    931     $current_site->path = $path;
    932     $current_site->site_name = ucfirst( $domain );
    933 
    934     if ( !is_multisite() ) {
     929    // When upgrading from single to multisite, assume the current site will become the main site of the network.
     930    // When using populate_network() to create another network in an existing multisite environment,
     931    // skip these steps since the main site of the new network has not yet been created.
     932    if ( ! is_multisite() ) {
     933        $current_site = new stdClass;
     934        $current_site->domain = $domain;
     935        $current_site->path = $path;
     936        $current_site->site_name = ucfirst( $domain );
    935937        $wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
    936         $blog_id = $wpdb->insert_id;
     938        $current_site->blog_id = $blog_id = $wpdb->insert_id;
    937939        update_user_meta( $site_user->ID, 'source_domain', $domain );
    938940        update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
    939     }
    940 
    941     if ( $subdomain_install )
    942         $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
    943     else
    944         $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
    945 
    946     flush_rewrite_rules();
     941
     942        if ( $subdomain_install )
     943            $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
     944        else
     945            $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
     946
     947        flush_rewrite_rules();
     948    }
    947949
    948950    if ( $subdomain_install ) {
Note: See TracChangeset for help on using the changeset viewer.