Rewrite post title and excerpt on update in publish-post - #212
Merged
Conversation
The update path wrote only post_content, while the SEO meta title and description were rewritten from the draft header on every run. A title corrected in the draft therefore stayed stale on the post even as the SEO title it should match was updated; on one post a "WooComerce" typo survived an update that changed everything else. The draft header is the source of truth for both fields, so the update now writes post_title and post_excerpt alongside the body. post_name and post_status stay untouched on update: rewriting a slug would silently break the live URL, and an update must not flip a draft live. A slug that differs from the draft now raises a warning instead, leaving the redirect decision to a human.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #211 — base is
fix/publish-post-wp-slash, so review that one first. Retarget tomainonce it merges.Follows up the note at the end of #210.
Problem
publish-post --updatewrote onlypost_content. Everything else on the update path came from the draft header and was rewritten on every run — SEO meta title, meta description, tags, category, featured image — but the post's ownpost_titleandpost_excerptwere not.The result is incoherent rather than merely incomplete: a title corrected in the draft stays stale on the post while
_genesis_title, derived from that same header, is updated to the corrected version. On one post a "WooComerce" typo survived an update that changed everything else, which is what surfaced this.Change
The update path now writes
post_titleandpost_excerptalongside the body. The draft header is authoritative for both.This is a behavior change, hence the minor bump to 5.17.0 rather than a patch. Anyone relying on the post title surviving an update will find it no longer does.
Deliberately not changed
post_name— rewriting a slug silently breaks the live URL and needs a redirect that this tool has no business creating. When the draft's slug differs from the stored one,publish-postnow warns and leaves it alone, so the drift is visible without acting on it.post_status— an update must not flip a draft live.--statusremains create-only.Both are commented in place so the omission reads as a decision rather than the same oversight repeating.
Verification
bash -npasses; the shell worker was regenerated withUPDATE_IDset and a\"-containing title, then linted withphp -lunder PHP 8.5 — valid, with the new warning and both fields correctly escaped through the heredocWARN:line follows the existing convention in the script and is picked up by the establishedgrep -E '^(WARN|ABORT|ERROR):'handler, so it prints throughprint_warnlike the category and tag warningstsc --noEmitpasses; the builtdist/tools/publishPost.jscarries both thewarn_slugemit and its parsingwp_slash()-wrapped, consistent with Slash post content before writing in publish-post #211