Automattic / Automattic/php-toolkit
bug: PushMD - path conflict on duplicate slug for posts in draft
- Lingua principale
- PHP
- Stelle
- 22
- Fork
- 5
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia in class-push-md-plugin.php, all’interno di export_wordpress_content(), e verifica come i post diventano percorsi Markdown del repository. Poi esamina ExportPathTest.php e aggiungi una copertura per più post in bozza o in sospeso che condividono uno slug, inclusa la priorità dei post pubblicati. Il lavoro è completato quando l’esportazione termina senza collisioni di percorso e le voci duplicate utilizzano percorsi di fallback basati sull’ID.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 76/100