#58423 closed defect (bug) (fixed)
Avoid an extra database query in populate_network()
Reported by: | SergeyBiryukov | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Upgrade/Install | Keywords: | has-patch good-first-bug needs-testing |
Focuses: | multisite, performance | Cc: |
Description
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 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.
Attachments (2)
Change History (11)
This ticket was mentioned in PR #4523 on WordPress/wordpress-develop by @sakibmd.
19 months ago
#2
- Keywords has-patch added
Trac ticket: https://core.trac.wordpress.org/ticket/58423
This ticket was mentioned in Slack in #core by mukeshpanchal27. View the logs.
19 months ago
#5
@
19 months ago
This ticket was discussed in the recent bug scrub.
The ticket have two different approach that need to test. @SergeyBiryukov can you take a look it. Thanks.
Props to @costdev
@
19 months ago
I made one more changes for this ticket. Removed extra get_userdata function call & moved the query inside is_multisite condition block
#6
@
19 months ago
I've created a PR about this issue @SergeyBiryukov. I think this solution may avoid the usage of extra database queries.
PR: https://github.com/WordPress/wordpress-develop/pull/4523
#7
@
19 months ago
Thanks for the patches!
Good catch on removing the get_userdata()
call in 58423-2.diff. I didn't notice it before, but I agree it's not really needed if we only use the ID.
#8
@
19 months ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 55869:
@SergeyBiryukov commented on PR #4523:
19 months ago
#9
Thanks for the PR! Merged in r55869.
Hi @SergeyBiryukov,
I removed the extra query from the place you suggested and I think this is valid.