Handle image import setup failures#657
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #657 +/- ##
=============================================
+ Coverage 74.57% 74.61% +0.04%
- Complexity 1754 1758 +4
=============================================
Files 85 85
Lines 7548 7561 +13
=============================================
+ Hits 5629 5642 +13
Misses 1919 1919
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dkotter
left a comment
There was a problem hiding this comment.
While I'm all for hardening existing code, I'm trying to understand in what situations these scenarios will happen. Reading the PR description doesn't give me a good idea of what scenarios these problems will occur or how to go about reproducing the problems myself.
What?
Adds explicit error handling for image import setup failures.
Why?
The image import ability writes generated image data to a temporary file and then sideloads it into the media library. If WordPress cannot create the temporary file, or if the image MIME type cannot be mapped to a file extension, the ability should return a clear
WP_Errorinstead of continuing with invalid file state.How?
Checks the result of
wp_tempnam()before writing image data. Also checks the file extension returned bywp_get_default_extension_for_mime_type()and deletes the temporary file before returning an error when the MIME type cannot be mapped.Use of AI Tools
AI assistance: Yes
Tool(s): Codex / ChatGPT
Model(s): GPT-5
Used for: Reviewing the image import control flow for unhandled failure paths and drafting the minimal guards. I reviewed the change and PR description before submitting.
Testing Instructions
WP_Errorinstead of attempting to sideload a file with an invalid extension.Screenshots or screencast
Not applicable. This PR does not change the UI.
Changelog Entry