Skip to content

Commit

Permalink
Merge pull request #4000 from edpittol/status-and-stats-command-refactor
Browse files Browse the repository at this point in the history
Apply ElasticPress filters to the requests in status and stats CLI commands
  • Loading branch information
felipeelia authored Nov 11, 2024
2 parents 3f6d473 + e8f46fc commit 746084c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions includes/classes/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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() ) );
Expand All @@ -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' );
Expand All @@ -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() ) );
Expand Down

0 comments on commit 746084c

Please sign in to comment.