WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 5 months ago

#32704 new defect (bug)

Upload path is not set correctly after switch_blog

Reported by: ilanco Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.0
Component: Upload Keywords: needs-patch
Focuses: multisite Cc:
PR Number:

Description

When blog is switched and still using old multisite upload folders, upload
directory is not set correctly, which makes functions like
wp_get_attachment_image_src() return the wrong url.

Attachments (1)

wp.patch (421 bytes) - added by ilanco 4 years ago.

Download all attachments as: .zip

Change History (5)

@ilanco
4 years ago

#2 @ilanco
4 years ago

wp_get_attachment_image_src() uses wp_get_attachment_url() which uses wp_upload_dir(). Looks like the bug is related.

#3 @jorbin
4 years ago

  • Focuses multisite added

@jeremyfelt - Can you triage this please and ensure it it isn't a 4.3 regression.

#4 @jeremyfelt
4 years ago

  • Component changed from General to Upload
  • Keywords needs-patch added
  • Version changed from trunk to 3.0

Hi @ilanco, thanks for the report. This is going to take some time to really dig into, so I don't have a great explanation immediately. This has existed for many releases and has never worked because of how constants are used to build the URLs when using the old ms-files. Even with the attached patch, the BLOGUPLOADDIR constant has already been set in the context of the first site and will be used even when building the URL for the switched site.

It may be possible to look for a default value for BLOGUPLOADDIR that contains the text wp-content/blogs.dir/#/files/ and replace that for use in $dir with current site's ID. I'm a little worried at what the consequences from that may be, though I haven't though through it too much. I'd much rather see that implemented by a plugin on the upload_dir filter first.

Switching is supported as of the deprecation of ms-files.php in #19235.

Note: See TracTickets for help on using tickets.