Ticket #22090: 22090.5.diff

File 22090.5.diff, 1.8 KB (added by ryan, 7 months ago)

Add a comment

Line 
1Index: wp-admin/includes/schema.php
2===================================================================
3--- wp-admin/includes/schema.php        (revision 22236)
4+++ wp-admin/includes/schema.php        (working copy)
5@@ -926,24 +926,26 @@
6        }
7        $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
8 
9-       $current_site = new stdClass;
10-       $current_site->domain = $domain;
11-       $current_site->path = $path;
12-       $current_site->site_name = ucfirst( $domain );
13-
14-       if ( !is_multisite() ) {
15+       // When upgrading from single to multisite, assume the current site will become the main site of the network.
16+       // When using populate_network() to create another network in an existing multisite environment,
17+       // skip these steps since the main site of the new network has not yet been created.
18+       if ( ! is_multisite() ) {
19+               $current_site = new stdClass;
20+               $current_site->domain = $domain;
21+               $current_site->path = $path;
22+               $current_site->site_name = ucfirst( $domain );
23                $wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time( 'mysql' ) ) );
24-               $blog_id = $wpdb->insert_id;
25+               $current_site->blog_id = $blog_id = $wpdb->insert_id;
26                update_user_meta( $site_user->ID, 'source_domain', $domain );
27                update_user_meta( $site_user->ID, 'primary_blog', $blog_id );
28-       }
29 
30-       if ( $subdomain_install )
31-               $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
32-       else
33-               $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
34+               if ( $subdomain_install )
35+                       $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
36+               else
37+                       $wp_rewrite->set_permalink_structure( '/blog/%year%/%monthnum%/%day%/%postname%/' );
38 
39-       flush_rewrite_rules();
40+               flush_rewrite_rules();
41+       }
42 
43        if ( $subdomain_install ) {
44                $vhost_ok = false;