BUG: Stuck WP-CLI sync generates a repeated output in the Sync Page #2737
Description
Describe the bug
Currently, if a WP-CLI sync process gets killed without clearing the index meta option, any visit to the Sync Page will output the same message over and over again, wrongly suggesting that the index is still running. That happens because the Sync page does not communicate directly to the WP-CLI PHP process but rather reads from an option stored in the database.
Steps to Reproduce
2. Run php -d max_execution_time=1 "$(which wp)" elasticpress index --per-page=2
so it times out
3. Visit the Sync Page
4. Click on "Show Log"
5. See the same message being outputted
6. Run wp elasticpress clear-index
7. See the sync page stopping to output the error
Expected behavior
Ideally, the plugin:
- Would not output the same message several times. The second and following times it'd update the same message it could say "Still processing (X seconds)", for example.
- WP-CLI sync wouldn't be stuck. Initial tests with a code like the following clear the index every time the process ends (even if timing out):
register_shutdown_function( array( $this, 'clear_index' ) );
We have to improve it though, as we want to tell the admin user that the last sync process actually failed.
Activity