[wp-trac] [WordPress Trac] #58423: Avoid an extra database query in populate_network()
WordPress Trac
noreply at wordpress.org
Mon May 29 16:55:27 UTC 2023
#58423: Avoid an extra database query in populate_network()
----------------------------------+----------------------------------------
Reporter: SergeyBiryukov | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 6.3
Component: Upgrade/Install | Version:
Severity: normal | Keywords: needs-patch good-first-bug
Focuses: multisite, |
performance |
----------------------------------+----------------------------------------
There is a `$site_user` value set in `populate_network()`:
{{{
$site_user = get_userdata(
(int) $wpdb->get_var(
$wpdb->prepare(
"SELECT meta_value
FROM $wpdb->sitemeta
WHERE meta_key = %s AND site_id = %d",
'admin_user_id',
$network_id
)
)
);
}}}
However, it is not actually used until [source:tags/6.2.2/src/wp-
admin/includes/schema.php?marks=1052,1068,1069#L1045 these lines further
in the function], inside an `if ( ! is_multisite() )` check:
{{{
update_user_meta( $site_user->ID, 'source_domain', $domain );
update_user_meta( $site_user->ID, 'primary_blog', $current_site->blog_id
);
}}}
To avoid an extra database query, the `get_userdata()` call can be moved
directly above these two lines.
Follow-up to [12756], [35575], [43628].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/58423>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list