Automattic / ElasticPress

A fast and flexible search and query engine for WordPress.
https://elasticpress.io
GNU General Public License v2.0
20 stars 7 forks source link

Skip wasteful term update index queuing #132

Closed rinatkhaziev closed 2 years ago

rinatkhaziev commented 2 years ago

Don't push posts to queue on a term update if 'name', 'slug', 'parent', 'term_taxonomy_id' are not modified during the update.

Description

Currently, the SyncManager operates on edited_term, unfortunately, even a simple wp_update_term that doesn't have any field update triggers the hook, so potentially anyone can go to the term edit screen, hit update, and cause a full re-index of documents with that term, which is not ideal.

This PR aims to address that with a bit of hackery:

  1. First on edit_terms - that happens PRIOR the term update we store the term
  2. Second, on edited_terms we fetch the new term and compare to the previously stored.
  3. Only index if the term was actually updated .
  4. Profit

Checklist

Please make sure the items below have been covered before requesting a review:

Steps to Test

rinatkhaziev commented 2 years ago

Closing in favor of the above-linked PR.

rinatkhaziev commented 2 years ago

Although this may approach may be desirable in ElasticPress upstream too, so not deleting the branch for now.