When using protected content the admin may show outdated information under some scenarios
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start by tracing the admin post-trash request to the Elasticsearch index request, then reproduce the stale listing on a minimal WordPress site. Verify how waiting for Elasticsearch refresh affects the next listing load and whether the behavior should be limited to admin changes. Done means trashed posts are absent immediately after the listing reloads without unnecessary manual refreshes.
Written by the indexing model from the issue text.
Description
Describe the bug
With protected content enabled interactions in the admin can result in inconsistent information.
Steps to Reproduce
- On a small site with minimal plugins
- Create a post and save it
- In the post listing, click on trash to put the item in the trash
- Note that when the page refreshes the item is still shown in the listing
- Refresh the listing, note that the item has now no longer in the list
Expected behavior
Clicking trash would result in the post no longer being listed
Environment information
- Plugins and version: I tested using 2.8 through 3.1
- Theme and version: default WP theme on 5.2.2
- Other installed plugin(s) and version(s): no other plugins
Cause and potential solution
This issue occurs because the request to update the post in Elasticsearch doesn't wait for Elasticsearch to commit the change, that is Elasticsearch returns immediately. The change isn't reflected in search results until the next refresh interval has fired which defaults to 1 second. When the WordPress admin loads again it does a search against an old copy of the index and gets outdated results back.
The potential solution is to add ?refresh=wait_for to the index request for the affected document(s). For performance I wouldn't recommend issuing a refresh command manually after indexing the document, only when making the index request. Manually issuing a refresh will just result in a doubled up refresh (because ES is already doing scheduled refreshes anyway) potentially causing more delay than necessary.
I also wouldn't use wait_for unless the command came from the admin page while users are making changes they would expect to be fresh on the next page load.
It maybe useful to allow for disable waiting in the event ES is configured with a longer than usual refresh interval.
- Dominant language
- PHP
- Stars
- 1.3k
- Forks
- 325
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from 10up/ElasticPress
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
10up/ElasticPress#4402 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 45/100
10up/ElasticPress#4390 ·
Maintainers usually reply within 1 day
-
[Release] 5.3.6Open
Difficulty 4/5 3-5 days Newbie friendliness 15/100
10up/ElasticPress#4388 ·
Maintainers usually reply within 1 day
-
Move AI Features from ElasticPress Labs to the ElasticPress PluginPossibly taken @ZacharyRener claimed this 124 days ago. Openenhancement
10up/ElasticPress#4316 · 2 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Convert Pointers class to functional componentPossibly taken @ZacharyRener claimed this 288 days ago. Openenhancement
10up/ElasticPress#4261 · 1 assignee ·
Maintainers usually reply within 1 day
All issues in 10up/ElasticPress
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/blocks-engine#5444 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Automattic/static-site-importer#2869 ·
Maintainers usually reply within 1 day
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug command:plugin-update scope:documentation
Difficulty 1/5 Under an hour Newbie friendliness 83/100
wp-cli/extension-command#572 ·