10up / distributor

Share content between your websites.
https://distributorplugin.com
GNU General Public License v2.0
628 stars 155 forks source link

Account for unpublished post statuses. #1156

Closed peterwilsoncc closed 9 months ago

peterwilsoncc commented 9 months ago

Description of the Change

Fixes various issues relating to post statuses:

Note

End-to-end tests are passing but the code to push the summary to the GitHub action's summary page is failing. This is reporting a false negative for successful tests.

See #1149

How to test the Change

  1. Install Distributor on a Multisite Install
  2. Create a sub site
  3. Generate some draft posts on the main site: wp post generate --count=5 --post_title="MS1 Draft" --post_author=1 --post_status=draft
  4. Generate some scheduled posts on the main site: wp post generate --count=5 --post_title="MS1 Scheduled" --post_author=1 --post_status=future --post_date="2123-11-20 21:46:18"
  5. Open the sub site's dashboard
  6. Go to Distributor > Pull Content
  7. Uncheck "pull as draft"
  8. Pull a scheduled post via the post's actions
  9. Return to new posts
  10. Uncheck "pull as draft"
  11. Pull a draft post via the post's action
  12. Return to new posts
  13. Uncheck "pull as draft"
  14. Check multiple scheduled posts' checkbox
  15. Select "pull" from the bulk action drop down
  16. Click "Apply"
  17. Return to new post
  18. Uncheck "pull as draft"
  19. Check multiple draft posts' checkbox
  20. Select "pull" from the bulk action drop down
  21. Click "Apply"
  22. Go the the All posts screen
  23. Ensure draft posts remain in draft
  24. Ensure scheduled posts are scheduled

Changelog Entry

Fixed - Prevent early publishing of scheduled posts when pulled internally.

Credits

Props @peterwilsoncc, @jeffpaul, @dkotter, @maxledoux, @pcrumm

Checklist:

jeffpaul commented 9 months ago

Let's also credit @maxledoux and @pcrumm for reporting the issue here as well.

dkotter commented 9 months ago

@peterwilsoncc This looks good to me and seems to fix the issues mentioned.

That said, one of the reported issues was around scheduled posts, in particular this was the reported problem:

  1. Within a multisite, create a scheduled post on Site A
  2. Either Push (though by default you can only Push published items) or Pull this content into another site on the network (Site B)
  3. On Site B, this post comes over in a published state, which is not desired
  4. If you then change this post on Site B to be a draft and then later update the original post on Site A (but keep it in a scheduled state), the post on Site B becomes published again

I tested these steps both on the develop branch and on this PR branch. In both cases, I couldn't reproduce the first reported problem. On both branches, Pushing or Pulling scheduled content brought that content over in a draft state, not a published state.

But I was able to reproduce the second problem both on develop and on this branch, so that part still needs addressed. I Pulled a scheduled post from Site A into Site B, it came over as a draft, I then updated the post on Site A and the post on Site B changed to published.

dkotter commented 9 months ago

Sorry, just to add more details to ^ above as I tested this a bit more.

If when Pulling or Pushing you leave the Pull/Push as Draft setting on, it will bring the item in a draft state, both on this PR and on develop (which is correct behavior). If you turn that setting off, on develop, it brings over scheduled items as published. With this PR, it brings over scheduled items as scheduled, which is correct.

So the remaining issue here is if you Pull a scheduled item in as a draft (which is the default) and you then update the original scheduled item, it turns the status from draft to published. I think ideal would be keeping it as draft but even changing it to scheduled would be better

peterwilsoncc commented 9 months ago

So the remaining issue here is if you Pull a scheduled item in as a draft (which is the default) and you then update the original scheduled item, it turns the status from draft to published. I think ideal would be keeping it as draft but even changing it to scheduled would be better

In ee56b99dcc587641641a2aabd13b1a897e645bcd I've pushed a change to prevent the post status from being updated when updating a post. The post status will always need to be changed on the distributed copy of the content.

Testing notes:

  1. Pull scheduled post as draft
  2. Update scheduled post on origin site
  3. Ensure post remains in draft on destination site
  4. Push published post as draft
  5. Ensure post is in draft state on destination site
  6. Update post on origin site
  7. Ensure post remains in draft on destination site.