Make default Markdown publication atomic and root-contained
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the default-layout write path in inc/class-wp-markdown-storage.php around lines 276-308, then read the legacy profile definition in inc/class-wp-markdown-content-layout-profiles.php. Run the existing default-layout and parent-promotion tests before changing the publication flow. Done means staged atomic replacement, root and symlink protection, preserved receipts and cleanup, and deterministic coverage for failed or interrupted publication.
Written by the indexing model from the issue text.
Description
Problem
The default post-type-hierarchy layout is the canonical production layout, but WP_Markdown_Storage::write_post() publishes with an in-place file_put_contents(..., LOCK_EX). A terminated or failed write can leave the authoritative Markdown file truncated or partial.
This legacy path also creates and traverses directories without applying the symlink-segment and root-containment checks used by custom layout profiles. A linked segment inside the canonical tree can redirect publication outside MARKDOWN_DB_CONTENT_DIR.
Relevant implementation: inc/class-wp-markdown-storage.php, default-layout write path around lines 276-308. The default profile is marked legacy in inc/class-wp-markdown-content-layout-profiles.php.
This is a concrete storage-integrity prerequisite for the pure-PHP canonical engine tracked in #232 and may also close one class of durability failure represented by #99.
Required outcome
- Publish default-layout Markdown through a same-directory staged file and atomic replacement.
- Preserve the previous complete canonical file whenever staging or publication fails.
- Validate every destination path segment beneath the canonical root and reject symlinks or directory replacement.
- Retain current hierarchy promotion, stale-path cleanup, indexing, and mutation receipts.
- Add deterministic coverage for failed publication, interrupted-write safety, and linked path segments.
Acceptance criteria
- Readers observe either the previous complete file or the next complete file, never a partial write.
- A failed replacement leaves the prior canonical post readable and unchanged.
- No default-layout write can escape the configured content root through a symlinked segment.
- Existing default-layout and parent-promotion tests continue to pass.
AI assistance
GPT-5.6 Sol via OpenCode reviewed the storage implementation, identified the publication and containment gaps, and helped structure this issue and its acceptance criteria. Chris Huber directed the review and issue creation.
- Dominant language
- PHP
- Stars
- 5
- Forks
- 1
- Avg merge
- 1h 41m
- Merged PRs (30d)
- 159
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Automattic/markdown-database-integration
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Automattic/markdown-database-integration#415 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
All issues in Automattic/markdown-database-integration
Similar issues
-
tooling
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
UX
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Automattic/safe-publish#594 ·