WordPress.org

Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#12549 closed defect (bug) (fixed)

Incorrect file URL for existing uploaded images (3.0-single to multi-site)

Reported by: kpdesign Owned by:
Milestone: 3.0 Priority: normal
Severity: blocker Version: 3.0
Component: Multisite Keywords: reporter-feedback
Focuses: multisite Cc:

Description

I upgraded an existing 2.9.2 single WordPress install to 3.0-alpha (latest nightly build), then converted it to multi-site yesterday. Image paths on the 3.0-alpha single install were fine, but once I converted it to multi-site, the existing uploaded image paths appear to be broken.

The images for the main site (now site 1) are located in wp-content/uploads/ and broken down into year/month folders.

The existing uploaded images fail to display in the following locations in the Admin area:

  • Post Thumbnail meta box: Gives me the option to remove the thumbnail, so it recognizes that an image had been assigned as the post thumbnail.
  • Add Image link above the post box: Shows one image in the gallery, but the image doesn't display.
  • Media Library: I'm presented with the list of existing uploaded images, but image thumbnails are missing.

I was able to get the images to display again by manually copying the year/month/ folders inside wp-content/uploads/ over to wp-content/blog.dir/1/files/.

However, the old files are still being referenced in older posts/pages, and plugins that allow image uploads (example: WP Cycle). Those will have to be fixed somehow to reflect the new image locations.

  1. Are there plans to include a migration script to move the existing year/month folders into the proper directory when converting from single to multi-site? If not, there should be a notice to the user during or after the conversion that they will need to manually move those folders into the correct directory.
  1. Existing references/links to these uploaded files will break if the user moves the files to wp-content/blog.dir/1/files/ and deletes the old folders in wp-content/uploads/. Possible to fix those references when converting from single to multi-site?

Attachments (1)

12549.diff (1.6 KB) - added by wpmuguru 10 years ago.

Download all attachments as: .zip

Change History (27)

#1 @kpdesign
10 years ago

  • Cc kpdesign added
  • Milestone changed from Unassigned to 3.0

#2 @wpmuguru
10 years ago

(In [13619]) allow existing media path on main site when converting to multisite, see #12549

#3 @wpmuguru
10 years ago

(In [13631]) additional checks on allow existing media path, see #12549

#4 @ryan
10 years ago

These changes broke the upload path on wordpress.com and could for other existing MU sites. UPLOADS and BLOGUPLOADDIR are assumed to be authoritative if they are set and should not be overridden by any value of upload_path. Perhaps the answer here is to not set UPLOADS or BLOGUPLOADDIR in ms-default-constants.php if they are not defined.

#5 @ryan
10 years ago

We need a means of applying this only to an upgraded primary blog.

#6 @ryan
10 years ago

  • Severity changed from normal to blocker

#7 @jimmcq
10 years ago

  • Cc jimmcq added

In the wp_upload_dir function of wp-includes/functions.php it seems like the $url variable should just be set to the value of get_option('upload_url_path').

I don't see why the next two if statements in that code attempt to override the value of $url, and ultimately had to comment them out to have the function return the expected value.

#8 @gazouteast
10 years ago

  • Cc gazouteast added

@wpmuguru
10 years ago

#9 @ryan
10 years ago

Should their be a check for is main site in there?

#10 @wpmuguru
10 years ago

(In [14680]) don't check upload_path in upgraded MU install, see #12549

#11 follow-up: @wpmuguru
10 years ago

  • Keywords reporter-feedback added

Can some folks with custom content dirs upgraded from MU test that patch and provide feedback?

#12 in reply to: ↑ 11 @wpmuguru
10 years ago

Replying to wpmuguru:

Can some folks with custom content dirs upgraded from MU test that patch and provide feedback?

s/that patch/[14680]/

#13 @ryan
10 years ago

I haven't tested yet, but that seems like it should do the trick. Will test this weekend.

#14 follow-up: @jimmcq
10 years ago

Why is it only overwrriten for the main site? Shouldn't your change also apply to all sites?

#15 in reply to: ↑ 14 @wpmuguru
10 years ago

Replying to jimmcq:

Why is it only overwrriten for the main site? Shouldn't your change also apply to all sites?

An upgraded MU install will have media folders as follows (excepting custom content dirs):

/wp-content/blogs.dir/1/files
/wp-content/blogs.dir/2/files
/wp-content/blogs.dir/3/files
...

A WP install after the network is enabled will have:

/wp-content/uploads
/wp-content/blogs.dir/2/files
/wp-content/blogs.dir/3/files
...

So, the only thing that needs to be excluded is a WP -> WP Network main site.

#16 follow-up: @jimmcq
10 years ago

I want to be able to save uploads to a completely different path... outside of wp-content and outside of the Wordpress install entirely.

I configured the upload_path and upload_url_path options, and I want Wordpress to use those options. I want $url = get_option('upload_url_path'), and I don't want the value of $url to change even though this is a multisite, and $upload_path isn't even related to WP_CONTENT_DIR or ABSPATH.

Does that make sense?

#17 in reply to: ↑ 16 @wpmuguru
10 years ago

Replying to jimmcq:

I want to be able to save uploads to a completely different path... outside of wp-content and outside of the Wordpress install entirely.

You can do that through a plugin and the UPLOADS & BLOGUPLOADDIR constants.

#18 @ryan
10 years ago

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

#19 @ryan
10 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Possibly the cause of #13483

#20 @wpmuguru
10 years ago

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

Closing again. The reporter in #13483 SQL imported MU blog into a WP -> WP Network. If he had upgraded his MU install to 3.0 the blogs would be fine.

#21 @wpmuguru
10 years ago

Forgot to include in the above note that the blogs had a custom content set up of some kind. Importing a MU blog using the default media handling/storage won't have that problem.

#22 @jimmcq
10 years ago

Here's the bit of logic that I'm not following... in function wp_upload_dir of function.php, there is a line that starts with if ( defined('UPLOADS'), but in function ms_upload_constants of ms-default-constants.php, UPLOADS get defined.

There isn't any way to un-define a constant... so why is that if ( defined('UPLOADS') check even there?

One of the early 3.0 nightly builds (before the first beta) introduced a change so that UPLOADS wasn't always defined. To me that seemed like the right thing to do, but now I find that UPLOADS is always defined no matter what again.

#23 follow-up: @gazouteast
10 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

QUOTE - wpmuguru — 8 weeks ago

Replying to jimmcq:

Why is it only overwrriten for the main site? Shouldn't your change also apply to all sites?

An upgraded MU install will have media folders as follows (excepting custom content dirs):
/wp-content/blogs.dir/1/files /wp-content/blogs.dir/2/files /wp-content/blogs.dir/3/files ...

A WP install after the network is enabled will have:
/wp-content/uploads /wp-content/blogs.dir/2/files /wp-content/blogs.dir/3/files ...
So, the only thing that needs to be excluded is a WP -> WP Network main site.
UNQUOTE

Just had a new site banjaxed by this uploads path issue.

Site was a WPMU 2.9.2 new build with a repository theme (modern style) being rbuilt as the home site theme. One additional blog was created for testing sub-blog to main-blog connectivity.

I upgraded to 3.0 using the automatic updater (didn't bother with any backups because this is still a very early build and I can restart from just a save of the theme folder).

Home theme is / should be blog 0 directly under blogs.dir, and the sub blog should be blog 1 in the /1/ folder according to what's said above.

Nope - there is only the folder for /1/ into which some newly uploaded images arrived using the standard post media uploader - arriving into /blogs.dir/1/uploads/2010/07/ - they should have arrived into /wp-content/uploads/2010/07/ except none of that folder path exists.

It seems that the upgrade has moved the home blog to /1/ and has overwritten the actual sub blog, even though it's still in the blogs list in admin.

The prime symptom of this is that in both admin and public of the home blog, no images of any type show in posts and pages drafts, published or whatever. The insert gallery from media uploader returns with just text links to images that do not display, and clicking those text links returns image not found. However on the server, the images are there and viewable from cPanel using the file viewer.

I've just done searches on WP.org and BP.org and there are literally hundreds of threads about non-displaying images, all started in the last few weeks.

I did have both a trac ticket and WP.org / MU and BP.org forum posts a while back reporting a fix (for image non-display) due to hosting services disabling fread (I think - might have been fopen) but all those have been removed in entirety and I cannot locate them.

I have 2 of my own sites completely killed by this, plus a client's site (upgraded from 2.9.2 single site to 3.0 single site - so it's not exclusively a multi-site issue). I will not be upgrading any more sites until this is absolutely assuredly fixed.

This issue is NOT resolved - 100's / 1000's of users have posted about this topic on WP's site forums in the last few weeks alone - it needs a major and urgent revisit.

Gaz

#24 @ryan
10 years ago

MU 2.9.2 used blogs.dir/1/, blogs.dir/2/, etc., not wp-content/uploads/2010/. It should continue doing so in 3.0 as long as MULTISITE has not been defined. /blogs.dir/1/ is correct for a 2.9.2 to 3.0 upgrade. We'll need more information to diagnose. What do the broken image links look like? Are you defining UPLOADS, UPLOADBLOGSDIR, or BLOGUPLOADDIR, or MULTISITE in your wp-config.php?

#25 in reply to: ↑ 23 @wpmuguru
10 years ago

Replying to gazouteast:

QUOTE - wpmuguru — 8 weeks ago

Home theme is / should be blog 0 directly under blogs.dir, and the sub blog should be blog 1 in the /1/ folder according to what's said above.

Nope - there is only the folder for /1/ into which some newly uploaded images arrived using the standard post media uploader - arriving into /blogs.dir/1/uploads/2010/07/ - they should have arrived into /wp-content/uploads/2010/07/ except none of that folder path exists.

You misread that somewhere. There is no blog id 0. Blog ids begin at 1. Look at your wp_blogs table.

#26 @wpmuguru
10 years ago

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

Looking at this thread: http://wordpress.org/support/topic/425009 & closing this ticket.

Note: See TracTickets for help on using tickets.