Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Anonymous/logged out comments are not indexed #2356

Closed
tomjn opened this issue Sep 21, 2021 · 3 comments
Closed

BUG: Anonymous/logged out comments are not indexed #2356

tomjn opened this issue Sep 21, 2021 · 3 comments
Assignees
Labels
bug Something isn't working high priority
Milestone

Comments

@tomjn
Copy link
Contributor

tomjn commented Sep 21, 2021

Describe the bug

When wp_insert_comment is called, a function is fired which maybe indexes the comment, but it has a capability check. If the user does not have the ability to edit comments, the function returns.

This is great for updating comments, but the same function is used for comment creation, breaking comments left by logged out users.

https://github.com/10up/ElasticPress/blob/develop/includes/classes/Indexable/Comment/SyncManager.php#L56-L66

The capability check in question: 9267d24

Steps to Reproduce

  1. Leave a comment as a logged out user on a post

Expected behavior

The guest comment should be indexed, it is not.

Environment information

  • Device: Macbook
  • OS: MacOS 11
  • Browser and version: Chrome 92 ( and others )
  • WordPress version: 5.8
  • ElasticPress version: "10up/elasticpress": "^3.6"
  • Elasticsearch version: 7.9.1
  • Where do you host your Elasticsearch server?
  • What ElasticPress features do you have currently active?

Additional context

We have a custom comment type for reactions, and found recently after updates that anonymous/guest users could no longer use this feature. On closer inspection it turns out it was not being indexed in ES. We know this because Elasticpress is disabled for queries when is_admin is true andd WP Admin reported the correct data, the frontend/REST API which has it enabled however did not update.

@tomjn tomjn added the bug Something isn't working label Sep 21, 2021
@mckdemps
Copy link
Contributor

@tomjn Thanks for submitting this, we're going to get it slotted in for a future release.

@mckdemps mckdemps added this to the 3.6.3 milestone Sep 21, 2021
@tomjn
Copy link
Contributor Author

tomjn commented Sep 21, 2021

@mckdemps awesome, I created a PR but I'm not 100% sure of its efficacy, it may be a good starting point rather than a full solution

@tomjn
Copy link
Contributor Author

tomjn commented Sep 21, 2021

I also think the capability checkss could be problematic, e.g. if a comment is edited because a plugin modified it automatically, even though the user does not have that capability, in that situation Elasticpress would not index the modification and it would desync

felipeelia added a commit that referenced this issue Sep 27, 2021
Index anonymous/guest comments, fixes #2356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

3 participants