Skip to content

Commit

Permalink
Do not sync empty queues
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum committed Nov 25, 2024
1 parent ecfb7bd commit d491c73
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions includes/classes/Indexable.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ public function bulk_index_dynamically( $object_ids ) {

$document = $this->prepare_document( $object_id );

if ( empty( $document ) ) {
continue;
}

/**
* Conditionally kill indexing on a specific object
*
Expand All @@ -404,6 +408,12 @@ public function bulk_index_dynamically( $object_ids ) {
$documents[] = $document_str;
}

if ( empty( $documents ) ) {
return [
new \WP_Error( 'ep_bulk_index_no_documents', esc_html__( 'It was not possible to create a body request with the document IDs provided.', 'elasticpress' ), $object_ids ),
];
}

$results = $this->send_bulk_index_request( $documents );

/**
Expand Down
4 changes: 4 additions & 0 deletions includes/classes/SyncManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ public function index_sync_queue() {

$current_blog_id = get_current_blog_id();
foreach ( $this->sync_queue as $blog_id => $sync_queue ) {
if ( empty( $sync_queue ) ) {
continue;
}

if ( $current_blog_id !== $blog_id ) {
switch_to_blog( $blog_id );
}
Expand Down

0 comments on commit d491c73

Please sign in to comment.