#51981 closed defect (bug) (wontfix)
wp_unique_filename() performance issue
Reported by: |
|
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)
#2
in reply to:
↑ 1
@
2 years 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!
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.