Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: count_users() returns an array #5499

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion search/includes/classes/class-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -1707,7 +1707,7 @@ public function filter__ep_post_mapping( $mapping ) {
public function filter__ep_user_mapping( $mapping ) {
$users_count = count_users();

if ( isset( $users_count->total_users ) && ( $users_count->total_users > self::USER_SHARD_THRESHOLD ) ) {
if ( isset( $users_count['total_users'] ) && ( $users_count['total_users'] > self::USER_SHARD_THRESHOLD ) ) {
$mapping['settings']['index.number_of_shards'] = 4;
}

Expand Down
13 changes: 4 additions & 9 deletions tests/search/includes/classes/test-class-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,13 +387,10 @@ public function test__vip_search_filter_filter__ep_user_mapping__large_site() {
Features::factory()->setup_features();

// Simulate a large site
$return_big_count = function () {
$counts = new stdClass();
$counts->avail_roles = 100;
$counts->total_users = 3000000;

return $counts;
};
$return_big_count = fn () => [
'avail_roles' => 100,
'total_users' => 3000000,
];

add_filter( 'pre_count_users', $return_big_count );

Expand All @@ -405,8 +402,6 @@ public function test__vip_search_filter_filter__ep_user_mapping__large_site() {
$settings = $mapping['settings'];
}
$this->assertEquals( 4, $settings['index.number_of_shards'] );

remove_filter( 'pre_count_users', $return_big_count );
}

public function test__vip_search_filter_ep_default_index_number_of_replicas() {
Expand Down
Loading