Skip to content

Harden custom status migration and the publish-timestamp workaround - #989

Merged
GaryJones merged 1 commit into
developfrom
vipplug-22-custom-status-hardening
Jun 8, 2026
Merged

Harden custom status migration and the publish-timestamp workaround#989
GaryJones merged 1 commit into
developfrom
vipplug-22-custom-status-hardening

Conversation

@GaryJones

Copy link
Copy Markdown
Contributor

Summary

Two long-standing rough edges in the custom-status module are tightened here.

The web status-migration handler used to reassign every post from one status to whatever target was submitted, without checking that the target was a real status. A typo or a forged value could therefore leave posts stranded in a status that does not exist. The handler now validates the submitted target against the full set of valid statuses — the core statuses plus every registered custom status. That set is exposed as a new public get_all_valid_statuses() method on the module, and the WP-CLI migrate command, which previously carried its own private copy of the same logic, now delegates to it so there is a single source of truth.

Separately, check_timestamp_on_publish is a workaround that writes post_status straight to the posts table when a post with no GMT timestamp transitions to publish, on both the edit.php bulk-edit path and the post.php single-publish path. It did no verification of its own. It now confirms the relevant edit nonce (bulk-posts, or update-post_<id>) and the per-post edit_post capability before writing. Because it runs on admin_init, it bails quietly rather than calling wp_die when a check fails, so legitimate requests are unaffected.

Test plan

  • composer cs and parallel-lint pass on the changed files.
  • Two integration tests were added and pass: one confirms the valid-status allow-list covers both core and custom statuses, the other confirms the publish workaround makes no write without a valid nonce but still applies with one.
  • The six pre-existing CustomStatusTest "post name not set" failures are unrelated to this branch and fail identically on develop.

Fixes VIPPLUG-22.

The custom-status migration handler reassigned posts to whatever target
status was submitted, so a bogus value could strand posts in a status
that does not exist; it now validates the target against the full set of
core and custom statuses. That set is exposed as a shared method so the
WP-CLI migrate command and the web handler agree on what is valid.

The publish-timestamp workaround also wrote directly to the posts table
on bulk and single publish requests without any verification of its own.
It now confirms the relevant edit nonce and the per-post edit capability
before writing, bailing quietly when either is missing since it runs on
admin_init.

Fixes VIPPLUG-22.
@GaryJones
GaryJones requested a review from a team as a code owner June 8, 2026 15:55
@GaryJones GaryJones added this to the Next milestone Jun 8, 2026
@GaryJones GaryJones self-assigned this Jun 8, 2026
@GaryJones
GaryJones merged commit 1324e55 into develop Jun 8, 2026
10 checks passed
@GaryJones
GaryJones deleted the vipplug-22-custom-status-hardening branch June 8, 2026 16:14
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.

1 participant