Repository navigation
Conversation
🤖 PR meta 🤖👋 Welcome👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @elphizu! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. 🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
What?
Closes #85158.
Delete incomplete attachments when an upload is cancelled after its original file has reached the server, including when finalization fails.
Why?
A failed
/finalizerequest shows an upload error but leaves the attachment in the Media Library without finalized metadata. Retrying the upload creates a duplicate.How?
Move attachment cleanup into
cancelItem()for top-level items with an attachment ID. Remove the separate deletion from the child total-failure path so the parent attachment is deleted once.Cleanup also applies to manual and silent cancellation. Child sideload cancellation preserves the parent when some sub-sizes succeeded. Deletion is best-effort and does not replace the original upload error.
Testing Instructions
*://localhost:8888/wp-json/wp/v2/media/*/finalize*, adjusting the origin for your environment.DELETE /wp/v2/media/<id>?force=truerequest succeeds.Screenshots or screencast
Use of AI Tools
Used OpenAI Codex to investigate the issue, add regression tests, and draft PR description.