Closed tw2113 closed 11 months ago
Positive evidence around this being a good change to potentially make:
https://wordpress.org/support/topic/auto-index-new-posts-and-updated-posts/
As a user of this plugin, I'd advocate for the proposed change. We were having some issues with some of our custom metadata being successfully attributed to our index records with the post watcher indexing records via the save_post
hook, but things worked as desired when using wp_after_insert_post
instead. I don't know what kind of consequences would result from making the change, but if it seems innocuous then I give two enthusiastic thumbs up!
PR ready for review https://github.com/WebDevStudios/wp-search-with-algolia/pull/388
This got deployed as part of 2.7.0.
The save_post hook works just fine and dandy with our default data. However, it is running before term and meta data has been saved.
This a potential issue because say I do the following.
The post gets pushed to the Algolia index, the attribute will get created, but the attribute is empty. This is because the meta had not been saved yet. Saving the post again without making any edits, repeats the process but this time the property is set to the saved value, because it was available.
If we were using the
wp_after_insert_post
hook for our listening, following the same steps would produce the results of having the property set correctly the first time, because we did the index sync after the meta has been saved to the database.Right now, the workaround would be to add each meta key you want to get sync'd the first time, to the
algolia_watch_post_meta_keys
filter, of which the callback does it's own post sync, which runs on these actions:added_post_meta
,updated_post_meta
,deleted_post_meta
However, I want to make sure we're not risking some sort of backwards compatibility issues.