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

git-svn-id: http://core.svn.wordpress.org/trunk@22240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan Boren 2012-10-15 21:41:29 +00:00
parent 5fee0949ac
commit ba79e04c10

View File

@ -926,25 +926,27 @@ We hope you enjoy your new site. Thanks!
}
$wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
$current_site = new stdClass;
$current_site->domain = $domain;
$current_site->path = $path;
$current_site->site_name = ucfirst( $domain );
if ( !is_multisite() ) {
// When upgrading from single to multisite, assume the current site will become the main site of the network.
// When using populate_network() to create another network in an existing multisite environment,
// skip these steps since the main site of the new network has not yet been created.
if ( ! is_multisite() ) {
$current_site = new stdClass;
$current_site->domain = $domain;
$current_site->path = $path;
$current_site->site_name = ucfirst( $domain );
$wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
$blog_id = $wpdb->insert_id;
$current_site->blog_id = $blog_id = $wpdb->insert_id;
update_user_meta( $site_user->ID, 'source_domain', $domain );
update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
if ( $subdomain_install )
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
else
$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
flush_rewrite_rules();
}
if ( $subdomain_install )
$wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
else
$wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
flush_rewrite_rules();
if ( $subdomain_install ) {
$vhost_ok = false;
$errstr = '';