#63989 closed enhancement (fixed)
is_user_member_of_blogs fetches all user meta keys
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | Users | Keywords: | has-patch needs-testing dev-feedback |
| Focuses: | performance | Cc: |
Description (last modified by )
[33771] introduced performance improvements to is_user_member_of_blog to combat the slowness of get_blogs_of_user
It does so by fetching all meta keys ($meta_key = ''). This makes it challenging to use "get_{$meta_type}_metadata" filter, as there's no good way to tell which part we want to short-circuit or apply special handling to.
The proposed approach is to change the logic do check for the specific blog's capability check name.
Roughly:
<?php // No underscore before capabilities in $base_capabilities_key. $base_capabilities_key = $wpdb->base_prefix . 'capabilities'; $site_capabilities_key = $wpdb->base_prefix . $blog_id . '_capabilities'; if ( 1 === $blog_id ) { $has_cap = get_user_meta( $user_id, $base_capabilities_key, true ); } else { $has_cap = get_user_meta( $user_id, $site_capabilities_key, true ); } return is_array( $has_cap );
Change History (10)
This ticket was mentioned in PR #9920 on WordPress/wordpress-develop by rinatkhaziev.
8 weeks ago
#1
- Keywords has-patch added
This ticket was mentioned in Slack in #core by wildworks. View the logs.
4 weeks ago
#4
@
4 weeks ago
- Keywords needs-testing dev-feedback added
This ticket was featured on today's 6.9 Bug Scrub. This ticket has had no activity since the PR was submitted. Testing and feedback are needed to move this ticket forward.
@rinatkhaziev commented on PR #9920:
3 weeks ago
#6
@jonnynews thank you, makes perfect sense. I've applied the suggestions.
@spacedmonkey commented on PR #9920:
3 weeks ago
#8
Committed
https://core.trac.wordpress.org/changeset/33771 introduced performance improvements to is_user_member_of_blog to combat the slowness of get_blogs_of_user
It does so by fetching all meta keys ($meta_key = ). This makes it challenging to use "get_{$meta_type}_metadata" filter, as there's no good way to tell which part we want to short-circuit or apply special handling to.
The proposed approach is to change the logic do check for the specific blog's capability check name.
Trac ticket: https://core.trac.wordpress.org/ticket/63989