Skip to content
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

Account for unpublished post statuses. #1156

Merged
merged 9 commits into from
Nov 22, 2023
Merged

Conversation

peterwilsoncc
Copy link
Collaborator

@peterwilsoncc peterwilsoncc commented Nov 21, 2023

Description of the Change

Fixes various issues relating to post statuses:

  • (network) when pulling scheduled posts, set the post date per original site
  • (network) when pulling draft posts, ensure the post is not published when "pull as draft" is unchecked

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:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@peterwilsoncc peterwilsoncc marked this pull request as ready for review November 21, 2023 03:45
@peterwilsoncc peterwilsoncc requested a review from a team as a code owner November 21, 2023 03:45
@peterwilsoncc peterwilsoncc requested review from iamdharmesh and removed request for a team November 21, 2023 03:45
@jeffpaul jeffpaul added this to the 2.0.2 milestone Nov 21, 2023
@jeffpaul jeffpaul requested a review from dkotter November 21, 2023 14:47
@jeffpaul
Copy link
Member

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

@dkotter
Copy link
Collaborator

dkotter commented Nov 21, 2023

@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
Copy link
Collaborator

dkotter commented Nov 21, 2023

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
Copy link
Collaborator Author

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 ee56b99 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.

@dkotter dkotter merged commit 3174de7 into develop Nov 22, 2023
9 of 10 checks passed
@dkotter dkotter deleted the fix/1149-post-statuses branch November 22, 2023 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants