mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Users: Ensure user counts remain accurate if users are added to or removed from the users table without corresponding usermeta entries being added or removed.
This has a slight performance impact on sites with a large number of users when the `time` strategy is used for counting users. Hopefully this impact will be negated by enhancements proposed in #38741. Props psoluch, dots, boonebgorges, ptbello, tharsheblows Fixes #29785 git-svn-id: https://develop.svn.wordpress.org/trunk@40560 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -857,7 +857,12 @@ function count_users($strategy = 'time') {
|
||||
$select_count = implode(', ', $select_count);
|
||||
|
||||
// Add the meta_value index to the selection list, then run the query.
|
||||
$row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
|
||||
$row = $wpdb->get_row( "
|
||||
SELECT {$select_count}, COUNT(*)
|
||||
FROM {$wpdb->usermeta}
|
||||
INNER JOIN {$wpdb->users} ON user_id = ID
|
||||
WHERE meta_key = '{$blog_prefix}capabilities'
|
||||
", ARRAY_N );
|
||||
|
||||
// Run the previous loop again to associate results with role names.
|
||||
$col = 0;
|
||||
@@ -881,7 +886,12 @@ function count_users($strategy = 'time') {
|
||||
'none' => 0,
|
||||
);
|
||||
|
||||
$users_of_blog = $wpdb->get_col( "SELECT meta_value FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'" );
|
||||
$users_of_blog = $wpdb->get_col( "
|
||||
SELECT meta_value
|
||||
FROM {$wpdb->usermeta}
|
||||
INNER JOIN {$wpdb->users} ON user_id = ID
|
||||
WHERE meta_key = '{$blog_prefix}capabilities'
|
||||
" );
|
||||
|
||||
foreach ( $users_of_blog as $caps_meta ) {
|
||||
$b_roles = maybe_unserialize($caps_meta);
|
||||
|
||||
Reference in New Issue
Block a user