Skip to content

Multisite support #1

Description

@pdclark

Multisite support basically comes down to three things:

The allowed path filter

class-404-template.php#L92
UBP checks to see if the requested $path from $_SERVER['REQUEST_URI'] contains $uploads['basedir'] with ABSPATH stripped out. So, for example, when requesting an image:

/wp-content/uploads/2012/10/image.jpg

$uploads['basedir'] without ABSPATH on a single site is:
wp-content/uploads
which exists in the requested path, so it passes.

On multisite, the requested $path would be:
/files/2012/10/image.jpg

But $uploads['basedir'] would be something like:
/wp-content/blogs.dir/3/files/ (where "3" is a blog ID)

So they don't match up. The check needs to be revised to accomidate multisite uploads directory path rewrites.

Download Path

class-404-template.php#L41
When an image is found, it's downloaded and saved to the local uploads directory. The download method, like allow_path, makes the assumption that the path to save the image to matches the path the image was requested from. In multisite, this isn't the case.

For example, single site:
image requested from: http://site.com/wp-content/uploads/2012/10/image.jpg
image saved to: ABSPATH.'/wp-content/uploads/2012/10/image.jpg'

But multisite:
image requested from: http://site.com/subsite/wp-content/uploads/2012/10/image.jpg
image saved to: ABSPATH.'/wp-content/blogs.dir/3/files/2012/10/image.jpg'

And "subsite" could also be a subdomain (subsite.site.com), or a mapped domain name. (subsite.com)

*Changes in 3.5 *

Trac ticket #19235

I haven't tested Nacin's final version of this in the 3.5 betas, but I'm pretty sure it's slated for release. Basically, in 3.5, there they'll be using wp-content/uploads/sites instead of wp-content/blogs.dir. wp_upload_dir() should account for this, but it of course needs to be tested, and the solutions for #1 and #2 need to be agnostic to whether they're running on 3.4- or 3.5+

To test any of these, you'd need to comment out the hook for requiring multisite to activate. But maybe you already did that? I was surprised to hear you activated the plugin on a multisite at all. Did it let you do it on the master site?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions