Project

General

Profile

Actions

Bug #12017

closed

Calls to wp_upload_dir() cause empty directory to be created

Added by Boone Gorges over 4 years ago. Updated over 4 years ago.

Status:
Resolved
Priority name:
Normal
Assignee:
Category name:
-
Target version:
Start date:
2019-10-25
Due date:
% Done:

0%

Estimated time:
Deployment actions:

Description

Previously: #5964

We continue to have a large number of empty directories in blogs.dir. They are of the form 5 from #5964 - /blogs.dir/{blogid}/files/{year}/{month}.

I just set up a logger to collect stacktraces, and I found that the main culprit appears to be wp_upload_dir(). By default, the second parameter $create_dir is true. So every time a plugin uses wp_upload_dir() to fetch the proper base for an upload path, without specifying that $create_dir should be false, it triggers the creation of the month/day subdirectory on the site in question.

There are a couple of primary culprits:
1. ass_loader() in the network-activated buddypress-group-email-subscription https://github.com/cuny-academic-commons/cac/blob/eaaa6af50fa399026fa8c9cc12c7a2a96ec937e6/wp-content/plugins/buddypress-group-email-subscription/bp-activity-subscription.php#L29
2. Mixin_Mvc_View_Instance_Methods::get_template_override_dir() in nextgen-gallery https://github.com/cuny-academic-commons/cac/blob/eaaa6af50fa399026fa8c9cc12c7a2a96ec937e6/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/mvc/package.module.mvc.php#L527
3. M_Static_Assets::get_static_override_dir(), also in nextgen-gallery https://github.com/cuny-academic-commons/cac/blob/eaaa6af50fa399026fa8c9cc12c7a2a96ec937e6/wp-content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/static_assets/module.static_assets.php#L102
4. bp_upload_dir() in BuddyPress, which is triggered along a couple different paths. This is mitigated somewhat by the fact that it's usually (always?) run with respect to BP_ROOT_BLOG.
5. Anthologize::__construct() in anthologize https://github.com/cuny-academic-commons/cac/blob/1.15.x/wp-content/plugins/anthologize/anthologize.php#L91

We should clean up existing empty directories and try to prevent future problems of this sort. I'll follow up in a comment with specific thoughts.

Actions

Also available in: Atom PDF