Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 10 years ago

#20527 closed feature request (wontfix)

Adding sunrise-like capability to ms-files

Reported by: isaacchapman's profile isaacchapman Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Multisite Keywords:
Focuses: Cc:


Currently sunrise.php is not included on multi-site file downloads as it is only called from /wp-includes/ms-settings.php, which is not included by /wp-includes/ms-files.php. Since mu-plugins and plugins are also skipped by SHORTINIT, there is no way to customize file downloading of which I am aware.

Because the existing sunrise.php include capability isn't exactly aligned with this issue, a separate file to be included makes sense to me. The attached diff will include a WP_CONTENT_DIR . '/sunrise_ms_files.php' file if SUNRISE_MS_FILES is defined in wp-config.php.

While my concern is securing file downloads for members-only sites (by including custom user-to-file authorization code), this fix could also allow for easily setting custom mime types. Example sunrise_ms_files.php content:

add_filter('upload_mimes', 'add_custom_mime_types');
function add_custom_mime_types($mimes = array()) {
	$mimes['abc'] = 'application/abracadabra';
	$mimes['def'] = 'application/defense';
	return $mimes;	

#20136 and #14659 are related to the MIME type issue.

Attachments (2)

ms-files.php.diff (423 bytes) - added by isaacchapman 12 years ago.
sunrise-ms-files.diff (1.8 KB) - added by isaacchapman 12 years ago.
Diff of wp-includes/ms-files.php and wp-admin/includes/plugin.php

Download all attachments as: .zip

Change History (8)

12 years ago


#1 @ocean90
12 years ago

Related: #19235

12 years ago

Diff of wp-includes/ms-files.php and wp-admin/includes/plugin.php

#2 @isaacchapman
12 years ago

#19235 is related in a somewhat opposite manner. Instead of using a central file serving script (ms-files.php), my understanding is #19235 is aimed at directly serving the files. (To offset partially the overhead of using ms-files.php in serving files I am using mod_xsendfile and defining WPMU_SENDFILE.)

The sunrise-ms-files.diff attachment includes reporting sunrise-ms-files.php (replaced the underscores with hyphens for WP consistency) as a drop-in on the Network Admin -> Plugins screen.

Last edited 12 years ago by isaacchapman (previous) (diff)

#3 @nacin
12 years ago

If we do #19235 (and we will), we will likely stop supporting ms-files.php. Certainly no more enhancements, in that case.

Rather than using wp-includes/ms-files.php, you could always use wp-content/ms-files.php and change your rewrite rules. This is how things worked in WordPress MU. Obviously, that means you won't get future updates to ms-files.php, so it may increase the burden a bit in making sure you end up with bugfixes. But, as I said, we're ideally going to kill ms-files.php usage for new installs (in 3.5, I think).

#4 @wpmuguru
12 years ago

  • Keywords close added

Recommending close.

#5 @SergeyBiryukov
12 years ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

#6 @jeremyfelt
10 years ago

#30159 was marked as a duplicate.

Note: See TracTickets for help on using tickets.