-
Notifications
You must be signed in to change notification settings - Fork 141
Fix: full-size source file not deleted on attachment removal #2364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
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 @@
## trunk #2364 +/- ##
=======================================
Coverage 69.17% 69.17%
=======================================
Files 90 90
Lines 7708 7708
=======================================
Hits 5332 5332
Misses 2376 2376
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:
|
…hment removal Adds a regression test for #2358 where deleting a media item does not remove the full-size converted source file (e.g. the AVIF/WebP version of an originally uploaded JPEG). The test calls webp_uploads_remove_sources_files() directly rather than wp_delete_attachment(), because WordPress's own file cleanup masks the bug by deleting the attached file (which after the plugin's replacement is the converted file itself). The root cause is in webp_uploads_remove_sources_files() which checks $original_mime_from_file via wp_check_filetype() on the current attached file. After the plugin replaces the attached file with the converted format, this check incorrectly matches the source's MIME type, causing the function to skip deleting it. Co-Authored-By: Claude Opus 4.5 <[email protected]>
adaa042 to
71568ba
Compare
|
So will the fix for the failure be worked on in this PR as well? I don't think we should merge a failing test. |
yes! I wanted to work on the test first to validate the issue and I can see it is failing as expected (https://github.com/WordPress/performance/actions/runs/21415667609/job/61663435120?pr=2364). I'll work on the fix next. |
Adds a fix and test for #2358 where deleting a media item does not remove the full-size converted source file (e.g. the AVIF version of an originally uploaded JPEG). The bug is in webp_uploads_remove_sources_files() which incorrectly skips the full-size source when the attached file's MIME type matches the source MIME type.
Summary
Fixes #2358
Relevant technical choices
Use of AI Tools
I used Claude to investigate the issue and write this test that demonstrates the failure. I also used Claude to suggest a solution to the problem.