Automattic / Automattic/php-toolkit

bug: PushMD - path conflict on duplicate slug for posts in draft

Open
#95 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
22
Forks
5
PR merge metrics
No merged PRs in 30d

Description

WordPress allows multiple non-published posts (e.g. draft, pending) to share the exact same post_name slug (e.g., my-draft-post). When exporting via Git (git clone / git fetch), PushMD attempts to write both posts to post/my-draft-post.md, causing a file path collision exception: Git export rejected because multiple WordPress entities map to the same PushMD path.

We can disambiguate duplicate slug collisions during export by falling back to ID-based paths (e.g., post/post-202.md) for colliding entries (giving published posts priority).

**Proposed Changes**
Push MD Plugin
[MODIFY] class-push-md-plugin.php
Update export_wordpress_content() to handle slug collisions gracefully.
Sort posts during export prioritize published posts before draft/pending/private posts.
When two or more posts resolve to the exact same repository markdown path, assign the human-readable slug path to the primary post and fallback to build_id_fallback_markdown_path($post) (post/post-.md or page/page-.md) for duplicate entries.

[MODIFY] ExportPathTest.php
Add unit tests verifying that multiple draft posts with identical slugs export cleanly without throwing exceptions, using ID fallback paths for duplicates.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in class-push-md-plugin.php at export_wordpress_content() and review how posts become repository markdown paths. Then inspect ExportPathTest.php and add coverage for multiple draft or pending posts sharing a slug, including the published-post priority. Done means the export completes without a path collision and duplicate entries use ID-based fallback paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.