mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-21 03:34:28 +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:
@@ -171,6 +171,31 @@ class Tests_User_CountUsers extends WP_UnitTestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 29785
|
||||
*
|
||||
* @dataProvider data_count_users_strategies
|
||||
*/
|
||||
public function test_count_users_should_not_count_users_who_are_not_in_posts_table( $strategy ) {
|
||||
global $wpdb;
|
||||
|
||||
// Get a 'before' count for comparison.
|
||||
$count = count_users( $strategy );
|
||||
|
||||
$u = self::factory()->user->create( array(
|
||||
'role' => 'editor',
|
||||
) );
|
||||
|
||||
// Manually delete the user, but leave the capabilities usermeta.
|
||||
$wpdb->delete( $wpdb->users, array(
|
||||
'ID' => $u,
|
||||
) );
|
||||
|
||||
$count2 = count_users( $strategy );
|
||||
|
||||
$this->assertEqualSets( $count, $count2 );
|
||||
}
|
||||
|
||||
function data_count_users_strategies() {
|
||||
return array(
|
||||
array(
|
||||
|
||||
Reference in New Issue
Block a user