Skip to content

Keep WordPress drafts out of the published archive - #64

Open
ssavutu wants to merge 1 commit into
mainfrom
fix/import-wordpress-post-status
Open

Keep WordPress drafts out of the published archive#64
ssavutu wants to merge 1 commit into
mainfrom
fix/import-wordpress-post-status

Conversation

@ssavutu

@ssavutu ssavutu commented Aug 12, 2026

Copy link
Copy Markdown
Member

What went wrong

Extractor never collected wp:status. With no status downstream there was nothing to filter on, so every <item> of post_type post became a live article.

On Delta that published 18 posts WordPress was holding back — 4 of its 5 private posts, its only pending one, and 13 drafts. Each had its own URL and <meta name="robots" content="index, follow">. Among them: a private 2016 sponsored post, and a story about a local business cited for violations.

Found while chasing an unrelated question about a category named "Paid Post" that appeared in Delta but showed zero published posts in WordPress — because the article behind it is private there.

The fix

  • Extractor.pywp:status added to _POST_ITEM_KEYS and _ARTICLE_SCALAR_TAGS. Both were needed: the first collects the key, the second maps the namespaced tag onto it.
  • ArticleTranslator — carries a normalized status, mirroring how _normalizeCommentStatus already absorbs WordPress's inconsistent casing.
  • ArticleFormatter — anything not publish gets pub_date = NULL.

A null pub_date is precisely how the CMS models a draft (PublishDueArticles keys on it), so a withheld post arrives as an editable draft and is absent from search, sitemap, feeds, comments and embeddings. creation_date is resolved before that point, so the piece keeps its date and still sorts correctly for an editor.

A missing status defaults to publish — an export predating this field must still import the archive as published rather than blanking ten thousand articles.

Verification

End-to-end through the real ExtractorTranslatorFormatter path against the production WXR:

midsommar                     wp:status=draft    pub_date=None   creation_date=2019-07-03 10:00:38
senate-campaign-guide-2016    wp:status=private  pub_date=None   creation_date=2016-11-06 05:14:09
beyond-disrespect             wp:status=pending  pub_date=None   creation_date=2017-12-01 12:50:20
li-receives-research-award    wp:status=publish  pub_date=2011-04-08 08:48:02          <- control

8 new tests in tests/test_article_status.py; all 15 test modules pass.

Prod

The 18 live posts were archived directly on Delta and now return 404. This change stops a reseed from putting them back.

Scope was closed by checking all 119 non-published WP posts: 26 have slugs (16 leaked), 93 do not (80 usable titles → 2 leaked; 7 others turned out to be duplicate-title pairs where WordPress publishes its own copy, so the Delta row is the published original under a collision-suffixed slug).

🤖 Generated with Claude Code

The extractor never collected wp:status, so there was nothing downstream to
filter on and every <item> of post_type "post" became a live article. On Delta
that published 18 posts WordPress was holding back -- 4 of its 5 private posts,
its only pending one, and 13 drafts -- each reachable at its own URL and marked
"index, follow". A private 2016 sponsored post and a story about a business
being cited for violations were among them.

Status now rides along from Extractor through the translator, and the formatter
withholds pub_date for anything that is not "publish". That is exactly how the
CMS models a draft (PublishDueArticles keys on a null pub_date), so a withheld
post lands as an editable draft rather than a live page. creation_date is
resolved before that point, so the piece keeps its date and still sorts.

A missing status defaults to "publish": an export taken before the extractor
collected the field must still import its archive as published rather than
blanking ten thousand articles.

The 18 already-published posts were archived directly in prod; this stops a
reseed from putting them back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant