fix(content-distribution): keep node post in status_on_publish when hub schedules#302
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a content-distribution edge case where hub-scheduled posts (post_status = future) could bypass status_on_publish on nodes, leading to unintended node publication via WordPress scheduling behavior.
Changes:
- Add explicit
futurepost-status handling inIncoming_Post::insert()to respectstatus_on_publish. - Add unit tests covering
futurebehavior for both non-publish and publishstatus_on_publishvalues.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
includes/content-distribution/class-incoming-post.php |
Adds a future-status branch to apply status_on_publish logic and avoid unintended node scheduling/publishing. |
tests/unit-tests/content-distribution/test-incoming-post.php |
Adds regression tests validating node behavior when receiving future status updates from the hub. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @wil-gerken, 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! ❤️ |
All Submissions:
Changes proposed in this Pull Request:
When a post is distributed to a node as a draft and the hub later schedules it, the node was auto-publishing the post regardless of the
status_on_publishsetting.The root cause:
post_status = 'future'fell through to theelsebranch inIncoming_Post::insert(), bypassing thestatus_on_publishcheck.Once a node post has a
futurestatus, WordPress schedules thepublish_future_postcron event, which then callswp_publish_post()directly. This bypassesclass-incoming-post.phpand thestatus_on_publishlogic.This change adds a
futurebranch that checksstatus_on_publishbefore applying the status.If
status_on_publishis a non-publish value (e.g.draft,pending), the node post stays in that status and the WP cron never schedules publication.If
status_on_publishispublishor unset, the node mirrors the hub'sfuturestatus so both sites publish on the same schedule.status_on_publishfuturedraftdraft<-- fixes the bugfuturependingpendingfuturepublishfuture(mirrors hub schedule)publishCloses
NPPM-2656Note: Following Copilot's reviews, I added some defensive guards for missing status_on_publish key across three access points in insert() (status handling, meta storage), plus an additional test covering this unset payload scenario.
How to test the changes in this Pull Request:
Before applying this PR:
/wp-admin/edit.php?post_type=post) and wait ~2 minutes for the post to arrive. It will show as Draft as expected.After applying this PR:
Other information: