[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
Tue Aug 17 20:42:25 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):
Replying to [comment:27 azaozz]:
> it will have to check 4 name variations for each `$number` increase.
This potentially can result in running `wp_unique_filename()` including
the two filters and `scandir()` 10-15 times. It's definitely going to be
quite slow :)
Yeah, but I honestly couldn't think of a more complete and correct way of
doing it until ...
>
> Also firing `wp_unique_filename` filter 10-15 times mostly for filenames
that will never be used seems like a regression. Perhaps we can pass the
alt filenames as another argument there, or maybe only the expected
filename after the image conversion.
... bingo! Adding the alternative filenames that a filter implementer
could check against would really help. :)
In the case of WP Offload Media, if there was an array of filenames with
alternate extensions that have passed the check along with the proposed
filename, we could quickly check our records of offloaded filenames for
the same dir to see whether there's a clash and do the usual version bump
we do.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53668#comment:28>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list