Multisite: Fix `count_users()` possibly querying incorrect roles when passed a different site ID.
The `time` strategy in `count_users()` queries users by role. However, the roles queried for were not affected by passing another site than the current one through the `$site_id` parameter, causing users having roles that were not queried for to appear as users without a role. This changeset fixes the issue by switching the site before retrieving the roles to query for. Fixes #42014. Built from https://develop.svn.wordpress.org/trunk@41653 git-svn-id: http://core.svn.wordpress.org/trunk@41487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b0aaa16b32
commit
5edfea22b9
|
@ -855,7 +855,13 @@ function count_users( $strategy = 'time', $site_id = null ) {
|
|||
$result = array();
|
||||
|
||||
if ( 'time' == $strategy ) {
|
||||
$avail_roles = wp_roles()->get_names();
|
||||
if ( is_multisite() && $site_id != get_current_blog_id() ) {
|
||||
switch_to_blog( $site_id );
|
||||
$avail_roles = wp_roles()->get_names();
|
||||
restore_current_blog();
|
||||
} else {
|
||||
$avail_roles = wp_roles()->get_names();
|
||||
}
|
||||
|
||||
// Build a CPU-intensive query that will return concise information.
|
||||
$select_count = array();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-alpha-41652';
|
||||
$wp_version = '4.9-alpha-41653';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue