WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 18 months ago

#20527 closed feature request (wontfix)

Adding sunrise-like capability to ms-files

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

Description

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:

<?php
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 2 years ago.
ms-files.php.diff
sunrise-ms-files.diff (1.8 KB) - added by isaacchapman 2 years ago.
Diff of wp-includes/ms-files.php and wp-admin/includes/plugin.php

Download all attachments as: .zip

Change History (7)

isaacchapman2 years ago

ms-files.php.diff

comment:1 ocean902 years ago

Related: #19235

isaacchapman2 years ago

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

comment:2 isaacchapman2 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 2 years ago by isaacchapman (previous) (diff)

comment:3 nacin2 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).

comment:4 wpmuguru18 months ago

  • Keywords close added

Recommending close.

comment:5 SergeyBiryukov18 months ago

  • Keywords close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.