BUG: Sync page shows a successful previous sync even if the index has been deleted #2962
Description
Describe the bug
The status of the ElasticPress Sync page is currently based on the results of the last sync operation. If a sync has not been performed yet the sync page will only offer a single option for syncing (#2858) and a "You just need to sync your content" admin notice will appear. If a sync has been performed the sync page will show the status of the last sync and display an additional option to delete and sync.
The problem is that if an index is deleted, such as by running the wp elasticpress delete-index
WP CLI command, the status of the sync page is still based on the last sync operation. This could result in a situation where an index no longer exists but the Sync page appears to show that things have been synced successfully and the admin notice instructing the user to sync their content will not appear.
Steps to Reproduce
- Install and set up ElasticPress then index your content
- In WP-CLI run
wp elasticpress delete-index
- Visit the Sync page.
Expected behavior
Ideally the sync page and admin notice should reflect whether or not an index exists, and if one does not exist they should behave as if a previous sync has not been performed.
I'm not sure whether the correct resolution would be to delete data about the last sync when the index is deleted, or to expand the logic of the sync page and admin notice to also check for the existence of the index. The former would be simpler but there may be reasons to keep the last sync data after deleting the index.
Activity