[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 21:39:02 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:30 azaozz]:
 > Okay, lets add that :)

 @ianmjones does a little dance. :)

 >
 > > 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.
 >
 > That would need another run through `wp_unique_filename()`, right?
 Probably quite rarely.

 Not at the moment, we do a quick check of the local filesystem and
 database ourselves. As we're generally at the end of the filter chain we
 avoid going round the horn ourselves too.

 > Wondering what would be better:
 > 1. A filter for `$new_number` inside the loop where the alt filenames
 are checked.
 > 2. The array of the alt filenames (and perhaps $number?) in the closing
 `wp_unique_filename` filter.

 Definitely (2) as the alt filenames are fast to check, and the $number
 would be neat as we could use that as a starting point if non-zero rather
 than starting from 1 ourselves as we currently have to.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53668#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list