[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 02:09:33 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 needs-unit-  |     Focuses:
  tests                                          |
-------------------------------------------------+-------------------------

Comment (by azaozz):

 Looking at 53668.2.diff, a bit unsure if the new
 `_wp_check_alternate_output_format_uniqueness()` is needed. Seems it
 repeats quite a bit of code/functionality from `wp_unique_filename()`.

 Agree that a good way to ensure the file name is unique is to check that
 file name with both possible extensions. To do that:

 1. Find if an image file is set to be converted.
 2. Increase the number that's appended to the file name until there are no
 matches for both extensions.

 It seems enough to loop twice the portion of code that increases the
 number and changes the file name. Alternatively that code can be extracted
 in a new function, then called in the loop, but don't see any benefits.
 Alt patch coming up.

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


More information about the wp-trac mailing list