Skip to content

Sync: End the sync when a batch comes back empty - #4408

Merged
felipeelia merged 1 commit into
10up:developfrom
rebeccahum:fix/index-stop-on-empty-batch
Nov 10, 2026
Merged

felipeelia merged 1 commit into
10up:developfrom
rebeccahum:fix/index-stop-on-empty-batch

Conversation

@rebeccahum

Copy link
Copy Markdown
Contributor

Description of the Change

When a sync batch comes back empty before the offset reaches the total (e.g. a post is published mid-sync), the sync reads ->ID from false, resets its cursor and starts over from the first object, and loops forever if the batch query never returns anything. This ends the sync on an empty batch instead.

How to test the Change

composer run test-single-site -- --filter TestIndexHelper (the new test fails without the change).

Changelog Entry

Fixed - Sync starting over, or never ending, when a batch comes back empty before the offset reaches the total.

Credits

Props @rebeccahum

Checklist:

🤖 Generated with Claude Code

When a batch had no objects but the offset had not reached the total, the
sync read ->ID from false, reset the pagination cursor and started over
from the first object. With a batch query that never returned objects it
looped forever.

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Privileged e2e (EP.io and @paidPlugins) started for 840a38cee2570fff82706ba6372f22992fa57fc5: https://github.com/10up/ElasticPress/actions/runs/42809447241

@felipeelia
felipeelia merged commit 44cec6a into 10up:develop Nov 10, 2026
28 of 29 checks passed
@felipeelia felipeelia added this to the 5.3.6 milestone Nov 10, 2026
felipeelia added a commit that referenced this pull request Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants