From e8f46fce5264baccf0c33282fc26df128e57b3af Mon Sep 17 00:00:00 2001 From: Eduardo Pittol Date: Wed, 12 Jun 2024 23:53:32 -0300 Subject: [PATCH] Apply ElasticPress filters to the requests in status and stats CLI commands --- includes/classes/Command.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/includes/classes/Command.php b/includes/classes/Command.php index 8546c68f0b..b2f9eb51e1 100644 --- a/includes/classes/Command.php +++ b/includes/classes/Command.php @@ -874,8 +874,6 @@ public function sync( $args, $assoc_args ) { public function status() { $this->connect_check(); - $request_args = [ 'headers' => Elasticsearch::factory()->format_request_headers() ]; - $registered_index_names = $this->get_index_names(); $response_cat_indices = Elasticsearch::factory()->remote_request( '_cat/indices?format=json' ); @@ -896,7 +894,7 @@ public function status() { $index_names_imploded = implode( ',', $index_names ); - $request = wp_remote_get( trailingslashit( Utils\get_host( true ) ) . $index_names_imploded . '/_recovery/?pretty', $request_args ); + $request = Elasticsearch::factory()->remote_request( $index_names_imploded . '/_recovery/?pretty' ); if ( is_wp_error( $request ) ) { WP_CLI::error( implode( "\n", $request->get_error_messages() ) ); @@ -919,8 +917,6 @@ public function status() { public function stats() { $this->connect_check(); - $request_args = array( 'headers' => Elasticsearch::factory()->format_request_headers() ); - $registered_index_names = $this->get_index_names(); $response_cat_indices = Elasticsearch::factory()->remote_request( '_cat/indices?format=json' ); @@ -942,7 +938,7 @@ public function stats() { $index_names_imploded = implode( ',', $index_names ); Elasticsearch::factory()->refresh_indices(); - $request = wp_remote_get( trailingslashit( Utils\get_host( true ) ) . $index_names_imploded . '/_stats/', $request_args ); + $request = Elasticsearch::factory()->remote_request( $index_names_imploded . '/_stats/' ); if ( is_wp_error( $request ) ) { WP_CLI::error( implode( "\n", $request->get_error_messages() ) );