-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(content-distribution): partial payload #205
feat(content-distribution): partial payload #205
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested this and it works great. Thanks!
I only added a small nit on return type.
$current_payload = $this->get_post_payload(); | ||
$current_payload_error = self::get_payload_error( $current_payload ); | ||
if ( is_wp_error( $current_payload_error ) ) { | ||
return $current_payload_error->get_error_message(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error should be returned here I think –not a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Fixed in ac91081
Hey @miguelpeixe, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
Implements support for distribution of partial payloads, given a list of post data keys to include in the payload.
The
Content_Distribution::distribute_post_partial( $post, $post_data_keys )
can be called directly to trigger a partial update, but it should be most commonly used in the context ofdistribute_queued_posts()
, which will decide on PHP shutdown whether to execute a partial or full distribution of a given post, based on the contents of the$queued_distributions
var, populated via thequeue_post_distribution( $post_id, $post_data_key );
method.E.g., if a post is saved and a post meta is updated in the same execution, the following will be called:
The above will trigger a single full post update on shutdown.
If only a post meta is updated on the execution:
A single partial update will run on shutdown.
This PR also improves the post meta coverage by hooking into
added_post_meta
anddeleted_post_meta
.Testing
wp post meta update {post_id} test_meta test_value
post_meta
,date_gmt
, andmodified_gmt
wp post meta delete {post_id} test_meta
post_meta
andtest_meta
is not there