replace_scope_draft deleted old draft entries with per-object db.session.delete but left the deleted objects in scope.entries. On a re-publish a caller (seed_display_scope) then matched a stale deleted entry via next() and store_inline_payload attached a payload to its dead entryid, failing the manifestpayloads->manifestentries FK on MySQL (1452); SQLite does not enforce it so the idempotency test passed. Clear the collection via the delete-orphan cascade instead, and flush pending inserts before the bulk payload delete so its autoflush cannot interleave a half-built insert. Verified publish + re-publish x3 on MySQL 5.6.
16 KiB
16 KiB