Make WordPress Core

Changeset 55869


Ignore:
Timestamp:
05/30/2023 02:32:25 PM (9 months ago)
Author:
SergeyBiryukov
Message:

Upgrade/Install: Avoid an extra database query in populate_network().

This moves the query for user ID of the new network's administrator closer to where the value is actually used.

Includes removing unnecessary get_userdata() call, as user ID is the only data needed here.

Follow-up to [12756], [35575], [43628].

Props nihar007, sakibmd, mukesh27, costdev, SergeyBiryukov.
Fixes #58423.

File:
1 edited

Legend:

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

    r55866 r55869  
    10451045    );
    10461046
    1047     $site_user = get_userdata(
    1048         (int) $wpdb->get_var(
    1049             $wpdb->prepare(
    1050                 "SELECT meta_value
    1051                 FROM $wpdb->sitemeta
    1052                 WHERE meta_key = %s AND site_id = %d",
    1053                 'admin_user_id',
    1054                 $network_id
    1055             )
    1056         )
    1057     );
    1058 
    10591047    /*
    10601048     * When upgrading from single to multisite, assume the current site will
     
    10801068        );
    10811069        $current_site->blog_id = $wpdb->insert_id;
    1082         update_user_meta( $site_user->ID, 'source_domain', $domain );
    1083         update_user_meta( $site_user->ID, 'primary_blog', $current_site->blog_id );
     1070
     1071        $site_user_id = (int) $wpdb->get_var(
     1072            $wpdb->prepare(
     1073                "SELECT meta_value
     1074                FROM $wpdb->sitemeta
     1075                WHERE meta_key = %s AND site_id = %d",
     1076                'admin_user_id',
     1077                $network_id
     1078            )
     1079        );
     1080
     1081        update_user_meta( $site_user_id, 'source_domain', $domain );
     1082        update_user_meta( $site_user_id, 'primary_blog', $current_site->blog_id );
    10841083
    10851084        // Unable to use update_network_option() while populating the network.
Note: See TracChangeset for help on using the changeset viewer.