Update existing draft articles instead of erroring on a repeat Micropub post #138
Loading…
Reference in a new issue
No description provided.
Delete branch "article-update-existing-draft"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
ArticleService::create()now looks for an existing article with the same title before inserting: if it finds a draft, it updates that article in place; if it finds an already-published one, it throws (mapped to a 400 byMicropubController) instead of silently colliding.Article's Sluggable config now setsincludeTrashed => trueas a safety net.ArticleusesSoftDeletes, andSluggable's uniqueness check ignores trashed rows by default, so a previously soft-deleted article's title could crash a brand new insert with a raw DB unique-constraint violation rather than getting auto-suffixed.This is the follow-up to #136: once that fix stopped swallowing exceptions, retrying a stuck "WireGuard" draft post from iA Writer surfaced exactly this - a
UniqueConstraintViolationExceptiononarticles_titleurl_uniquefrom a pre-existing trashed row with the same title.Test plan
./vendor/bin/sail test- 380 passed (3 new tests: draft-gets-updated, published-title-conflicts-with-error, trashed-slug-gets-suffixed)./vendor/bin/pint --test- clean🤖 Generated with Claude Code