WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 9 months ago

#51981 closed defect (bug) (wontfix)

wp_unique_filename() performance issue

Reported by: deividasjank Owned by:
Milestone: Priority: normal
Severity: major Version: 5.3
Component: Media Keywords:
Focuses: performance Cc:

Description

Hello. I am new in this community and this is my first ticket, so don't judge me :)

Recently I have updated our project's WP from 4.9.8 to 5.5.3. We have noticed that image upload time has significantly increased from 2s to 20s. We are using S3 upload and our images count is huge.

Then I have noticed that wp_unique_filename() logic has been changed. Basically all of the upload time is consumed by @scandir(). We have a lot of files so this is not performing well.

<?php
if ( null === $files ) {
  // List of all files and directories contained in $dir.
  $files = @scandir( $dir );
}

Then I have tried to revert this function to previous version and that solution to check one file at a time was performing much better.

<?php
while ( file_exists( $dir . "/$filename" ) ) {...

I think this performance issue should be fixed.

Change History (4)

#1 follow-up: @ocean90
12 months ago

  • Version changed from 5.5.3 to 5.3

Hello @davidakennedy, welcome to WordPress Trac!

Thanks for the report. This is kind of a known issue and a filter was added in #50587 to support using a custom implementation of a check. In your case you might be interested in how this was handled in the S3 Uploads plugin.

#2 in reply to: ↑ 1 @deividasjank
12 months ago

Replying to ocean90:

Hello @davidakennedy, welcome to WordPress Trac!

Thanks for the report. This is kind of a known issue and a filter was added in #50587 to support using a custom implementation of a check. In your case you might be interested in how this was handled in the S3 Uploads plugin.

Thank you!

#3 @deividasjank
12 months ago

  • Resolution set to wontfix
  • Status changed from new to closed

#4 @desrosj
9 months ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.