[wp-trac] [WordPress Trac] #31066: wp_upload_dir calls wp_mkdir_p on each invocation

WordPress Trac noreply at wordpress.org
Wed Jun 10 23:19:23 UTC 2015


#31066: wp_upload_dir calls wp_mkdir_p on each invocation
----------------------------+------------------------------
 Reporter:  rmccue          |       Owner:
     Type:  defect (bug)    |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Filesystem API  |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:
----------------------------+------------------------------
Changes (by kovshenin):

 * keywords:   => has-patch


Comment:

 I just witnessed a profile of a page that rendered close to a hundred
 thumbnails, which is not that many if you think about it, but attempting
 to create an uploads directory 300 times in a single request is definitely
 overkill, not only for high-latency and slow filesystems.

 In [attachment:31066.diff] I added a new `$mkdir` argument to
 `wp_upload_dir()`. Initially I wanted it to default to false, but given
 that many plugins expect the function to create the uploads directory, I
 settled on true by default. Adjusted a couple of media functions which
 clearly shouldn't be creating any directories.

 Also added a `wp_mkdir_p_override` filter to allow plugins to override the
 whole function, or disable it completely with `__return_true`.

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


More information about the wp-trac mailing list