[wp-trac] [WordPress Trac] #53668: Generated images for one file can be overwritten by another with the same name when mapping mime types for generated images
WordPress Trac
noreply at wordpress.org
Fri Aug 13 13:10:00 UTC 2021
#53668: Generated images for one file can be overwritten by another with the same
name when mapping mime types for generated images
----------------------------------------------------+---------------------
Reporter: ianmjones | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.8.1
Component: Media | Version: 5.8
Severity: normal | Resolution:
Keywords: has-patch needs-testing has-unit-tests | Focuses:
----------------------------------------------------+---------------------
Comment (by ianmjones):
@azaozz Thanks for taking a look at my patch and suggesting a variation
that does not use a helper function and a reduced iteration set.
However, I think your version misses out on a key reason that I used a
helper function and recursion. Here's the scenario...
1. Upload `picture.png` **before** any implementation of the
`image_editor_output_format` filter (or just remove the generated
thumbnails).
2. Implement `image_editor_output_format` to generate `jpg` thumbnails for
the `image/png` type.
3. Upload `picture.jpg`.
4. Regenerate thumbnails for `picture.png`.
With your patch I believe `picture.jpg` will not be versioned on upload,
meaning that when the thumbnails are regenerated for `picture.png` they
will overwrite the thumbnails for `picture.jpg`.
You can see me testing my working solution for this scenario in my
original session for working on this bug, the following link should be
direct to the timestamp of 1 hour 40 mins.
https://youtu.be/sMDcIOnEvjU?t=6024
This particular scenario also happens to be important for a certain plugin
that offloads media and optionally removes the files from the server. 😉️
I've updated my patch to include an assertion that covers this scenario,
and also added the function name change that you made.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53668#comment:20>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list