WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#13733 closed defect (bug) (fixed)

MS Main Site Uploads Inconsistency

Reported by: filosofo Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords: has-patch reporter-feedback dev-feedback
Focuses: Cc:

Description

When you have a fresh MS install with no uploads directory set up for the main site, according to the following logic in wp-includes/functions.php:

2129         if ( empty($upload_path) ) {
2130                 $dir = WP_CONTENT_DIR . '/uploads';
2131         } else {
2132                 $dir = $upload_path;
2133                 if ( 'wp-content/uploads' == $upload_path ) {
2134                         $dir = WP_CONTENT_DIR . '/uploads';
2135                         $main_override = defined( 'MULTISITE' ) && is_main_site();
2136                 } elseif ( 0 !== strpos($dir, ABSPATH) ) {
2137                         // $dir is absolute, $upload_path is (maybe) relative to ABSPATH
2138                         $dir = path_join( ABSPATH, $dir );
2139                 }
2140         }

The uploads directory is set to wp-content/uploads with no way of changing it. This differs from the other, non-main sites.

Since the main site is using the uploads directory, it should have the uploads directory setting fields available to change it, just like non-MS WP. Hence patch allows the main site to change the uploads directory just like non-MS WP.

Attachments (3)

allow-main-site-upload-access.13733.diff (455 bytes) - added by filosofo 4 years ago.
13733.2.diff (1.8 KB) - added by wpmuguru 4 years ago.
13733.3.diff (1.6 KB) - added by wpmuguru 4 years ago.
revision of 13733.2.diff

Download all attachments as: .zip

Change History (15)

comment:1 follow-up: wpmuguru4 years ago

  • Milestone changed from 3.0 to Future Release

Upload directories in multisite are determined by the UPLOADS & BLOGUPLOADSDIR constants. The only exception to that is if the original single WP content directory was wp-content/uploads.

Making the media upload handling more customizable internal to WP (it can be done with plugins) would definitely be an enhancement.

comment:2 in reply to: ↑ 1 ; follow-up: filosofo4 years ago

  • Milestone changed from Future Release to 3.0

Replying to wpmuguru:

Upload directories in multisite are determined by the UPLOADS & BLOGUPLOADSDIR constants. The only exception to that is if the original single WP content directory was wp-content/uploads.

Making the media upload handling more customizable internal to WP (it can be done with plugins) would definitely be an enhancement.

Please re-read the ticket. Thas to do with the main site, which from the code above is not using those constants. That's the point of ticket and why it's inconsistent.

comment:3 filosofo4 years ago

Hmm. I kinda like "thas" as an abbreviation for "this has." I might use it deliberately in the future. :)

comment:4 in reply to: ↑ 2 wpmuguru4 years ago

  • Milestone changed from 3.0 to Future Release

Replying to filosofo:

Please re-read the ticket. Thas to do with the main site, which from the code above is not using those constants. That's the point of ticket and why it's inconsistent.

Please re-read my response: The only exception to that (UPLOADS & BLOGUPLOADSDIR) is if the original single WP content directory was wp-content/uploads.

If the upload_path option on the main site in a 3.0 network is not wp-content/uploads the constants are used. Try changing the upload_path to something other than wp-content/uploads in the edit site screen to verify.

comment:5 wpmuguru4 years ago

  • Keywords reporter-feedback dev-feedback added

Can a few people with custom content directories & upgraded MU installs give the patch I'm attaching a run and let me know if it causes any issues?

wpmuguru4 years ago

comment:6 follow-up: nacin4 years ago

  • Keywords changed from has-patch, reporter-feedback, dev-feedback to has-patch reporter-feedback dev-feedback

The blog_id bit shouldn't be necessary, is_main_site() defaults to $current_blog->blog_id.

comment:7 in reply to: ↑ 6 wpmuguru4 years ago

Replying to nacin:

The blog_id bit shouldn't be necessary, is_main_site() defaults to $current_blog->blog_id.

switch_to_blog() doesn't update the $current_blog object. For this use, we need to know if the switched blog is the main site.

comment:8 wpmuguru4 years ago

On second thought, if it's switched the override doesn't apply anyway.

wpmuguru4 years ago

revision of 13733.2.diff

comment:9 wpmuguru4 years ago

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

(In [15197]) allow custom content dir in WP 3.0 main site, fixes #13733

comment:10 nacin4 years ago

  • Milestone changed from Future Release to 3.0

comment:11 follow-up: Ipstenu4 years ago

If this fix went into 3.0 RC3, then it had the WEIRD effect of breaking my uploads settings for my main site (which is site #3 and not #1).

I had to MANUALLY go into the MS backend and change Upload Path from blank to wp-content/blogs.dir/3/files and Upload Url Path to http://domain.com/files for it to work like it used to.

comment:12 in reply to: ↑ 11 wpmuguru4 years ago

Replying to Ipstenu:

If this fix went into 3.0 RC3, then it had the WEIRD effect of breaking my uploads settings for my main site (which is site #3 and not #1).

I had to MANUALLY go into the MS backend and change Upload Path from blank to wp-content/blogs.dir/3/files and Upload Url Path to http://domain.com/files for it to work like it used to.

That's a side affect of your install being one of the alpha & beta test installs. We made several fixes to this along the way between February and now. A new network install will have the correct option values.

Sites that are imported via SQL may need the option value added.

Note: See TracTickets for help on using tickets.