Skip to content

Preserve scheduled and private status when publishing custom posts#25552

Open
crazytonyli wants to merge 5 commits into
trunkfrom
bugfix/preserve-prepublish-status
Open

Preserve scheduled and private status when publishing custom posts#25552
crazytonyli wants to merge 5 commits into
trunkfrom
bugfix/preserve-prepublish-status

Conversation

@crazytonyli
Copy link
Copy Markdown
Contributor

Description

The publish path was unconditionally setting params.status = .publish at four call sites in CustomPostEditorService. It now preserves .future and .private, and only normalizes drafts/pending/nil to .publish.

I have added a test case under Tests/AgentTests/post-editor/ that covers the private case end-to-end.

The custom post publish flow flattened the user's selected status to
.publish in both the Post Settings and editor-content paths, dropping
.future (scheduled) and .private (password/private visibility). The save
action now normalizes status only for selections that lack their own
publishing semantics (drafts, pending, or unspecified), and preserves
.future and .private as the user selected them.
@crazytonyli crazytonyli added this to the 26.9 milestone May 11, 2026
@crazytonyli crazytonyli requested a review from jkmassel May 11, 2026 03:03
@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 11, 2026

App Icon📲 You can test the changes from this Pull Request in WordPress by scanning the QR code below to install the corresponding build.
App NameWordPress
ConfigurationRelease-Alpha
Build Number32293
VersionPR #25552
Bundle IDorg.wordpress.alpha
Commit87b6edd
Installation URL628m3njbjbi80
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@wpmobilebot
Copy link
Copy Markdown
Contributor

wpmobilebot commented May 11, 2026

App Icon📲 You can test the changes from this Pull Request in Jetpack by scanning the QR code below to install the corresponding build.
App NameJetpack
ConfigurationRelease-Alpha
Build Number32293
VersionPR #25552
Bundle IDcom.jetpack.alpha
Commit87b6edd
Installation URL4amo9bcka2kog
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

/// publishing semantics (scheduled, password/private visibility); every
/// other selection — draft or pending — collapses to `.publish` so the
/// post is published normally.
func normalizedPublishStatus() -> PostStatus {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if a user without publishing permission goes through this flow? Will it preserve pending?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Addressed in the latest commit.


case (.newPost(let existing), true):
var params = settings.makeCreateParameters(from: existing, taxonomies: taxonomies)
params.status = params.status?.normalizedPublishStatus() ?? .publish
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not related to this PR, but can params.status ever be nil?

If not, maybe it doesn't need to be optional and we could flatten this out? Or maybe it should be able to be nil to represent "the user hasn't told us what they want"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with it being non-optional. We can always give new posts a default "draft" status, which sounds very reasonable to me.

@@ -0,0 +1,32 @@
# Preserve Private Visibility When Publishing a Custom Post
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have one of these for the scheduled case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have included more status in a new test case 87b6edd

@dangermattic
Copy link
Copy Markdown
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 26.9. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@crazytonyli crazytonyli requested a review from jkmassel May 22, 2026 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants